/**
  * @Route("/sample/form", name="private.sample.form")
  * @Template()
  */
 public function sampleFormAction(Request $request)
 {
     $form = $this->createForm(EmailMessageType::class, null, ['render_submit_button' => true]);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $data = $form->getNormData();
         $data['email'] = $this->get('fos_user.util.email_canonicalizer')->canonicalize($data['email']);
         $data['attachments'] = array_filter($data['attachments'], function ($e) {
             return $e instanceof \Symfony\Component\HttpFoundation\File\UploadedFile;
         });
         $to = ['name' => $data['name'], 'email' => $data['email']];
         $from = ['name' => $this->container->getParameter('app_name'), 'email' => $this->get('fos_user.util.email_canonicalizer')->canonicalize($this->container->getParameter('mailer_default_email'))];
         $bodyPlainText = strip_tags($data['body']);
         $bodyPlainText = trim($bodyPlainText);
         /**
          * @var \AppKernel
          */
         $kernel = $this->get('kernel');
         $tmpDir = implode(DIRECTORY_SEPARATOR, [$kernel->getCacheDir(), 'swiftmailer', 'tmp']);
         if (false === is_dir($tmpDir)) {
             mkdir($tmpDir, 0777, true);
         }
         if (false === is_writable($tmpDir)) {
             throw new \Exception(sprintf('Directory %s is not writable.', $tmpDir));
         }
         $message = \Swift_Message::newInstance()->setSubject($data['subject'])->setFrom($from['email'], $from['name'])->setTo($to['email'], $to['name'])->setBody($data['body'], 'text/html')->addPart($bodyPlainText, 'text/plain');
         foreach ($data['attachments'] as $a) {
             $fname = tempnam($tmpDir, 'att');
             copy($a->getRealPath(), $fname);
             $attachment = \Swift_Attachment::fromPath($fname, $a->getMimeType())->setFilename($a->getClientOriginalName());
             $message->attach($attachment);
         }
         $result = $this->get('mailer')->send($message);
         if ($result !== 1) {
             throw new \Exception($result);
         }
         ldd($result);
     }
     return ['form' => $form];
 }
 /**
  * @Route("/read")
  * @Template()
  */
 public function readAction()
 {
     $em = UtilRepository2::getEntityManager();
     $repo = $this->getDoctrine()->getRepository("BaseBundle:Litigante");
     $tramite = $repo->obtenerXEscritoDemanda(18);
     ldd($tramite);
     //        $this->get('comunes.motorgtr')->registrarTramite($tramite);
     //        $em->flush();
     //        $em->persist($tramite);
     //        $em->flush();
     die('paco');
     //        $this->parameters = UtilRepository2::createFiltersFromRequest($this->getRequest());
     //        $method = $this->method;
     //        $result = $repo->$method($this->parameters);
     //        return new \Symfony\Component\HttpFoundation\Response(json_encode($result));
     //        $obj = $repo->generateEnumFromCollection($repo->filterObjects(array('tipoEstado'=> \backend\ComunBundle\Enums\ETipoEstado::Tramite)),'EEstadoTramite');
     //        $obj = $repo->generateEnumToEntity();
     //        $var['total']= UtilRepository2::getSession()->get('total');
     //        ld($table);
     //        ldd(\backend\ComunBundle\Util\UtilRepository2::getEntityManager()->getRepository('ComunBundle:'.$table)->filterObjects());
     //        ldd(\backend\BiomexpressServicesBundle\Manager\BiomexpressServiceManager::authenticate(1, 1));
     //       ldd($obj);
 }
Exemple #3
0
            $app->redirect($document->redirect);
        }
        // Render the document.
        $document->render();
        // Render the document into the template, and display it.
        $output = $app->view()->render($document->template, ['page' => ['title' => $document->header['title'], 'content' => $document->output, 'header' => $document->header]]);
        $app->halt(200, $output);
    } catch (Exceptions\NoContentException $e) {
        if ($app->get('app.settings.debug')) {
            throw $e;
        } else {
            $app->notFound();
        }
    } catch (\Exception $e) {
        if ($app->get('app.settings.debug')) {
            ldd($e);
        } else {
            $app->error($e);
        }
    }
});
// Handle missing resources.
$app->map('notFound', function () use($app) {
    $output = $app->view()->render($app->get('app.templates.error404.file'), []);
    $app->halt(404, $output);
});
// Handle internal errors.
$app->map('error', function (\Exception $e) use($app) {
    $output = $app->view()->render($app->get('app.templates.error404.file'), ['error' => $e]);
    $app->halt(500, $output);
});
 /**
  *
  * @Given /^I dump$/
  */
 public function iDump()
 {
     ldd(substr($this->getPage()->getHtml(), 0, 9000));
 }
Exemple #5
0
 public function getTableSortByRequestOld()
 {
     $sortMap = $this->mapSorts();
     $sortArray = array();
     foreach ($sortMap as $key => $sort) {
         $sortColIndex = $this->container->get('request')->get('iSortCol_' . $key);
         if ($sortColIndex != null) {
             $sortDir = $this->container->get('request')->get('sSortDir_' . $key);
             $sortArray[$sortMap[$key]] = $sortDir;
         }
     }
     ldd($sortArray);
     return $sortArray;
 }