function it_should_return_converted_data(Request $request, Convert $convert, EngineInterface $templating) { $result = $this->indexAction($request); $convert->convert(Argument::any([]), Argument::any('string'))->shouldBeCalled(); $convert->convert(Argument::any([]), Argument::any('string'))->willReturn('string'); $templating->render('default/index.html.twig', array('result' => $result)); }
/** * {@inheritDoc} */ public function sendResettingEmailMessage(UserInterface $user) { $template = $this->parameters['resetting_password.template']; $url = $this->router->generate('fos_user_resetting_reset', array('token' => $user->getConfirmationToken()), true); $rendered = $this->templating->render($template, array('confirmationUrl' => $url, 'user' => $user)); $this->sendEmailMessage($rendered, $user->getEmail()); }
public function indexAction(Request $request, $configurationId) { $configuration = $this->getConfigurationOr404($configurationId); $pagination = $this->createPagination($configuration, $request); $reports = $this->reportManager->getJobReportsByConfiguration($configuration, $pagination->getOffset(), $pagination->getPerPage()); return $this->templating->renderResponse('AurejaJobQueueBundle:JobReport:index.html.twig', ['configuration' => $this->getConfigurationOr404($configurationId), 'pagination' => $pagination, 'reports' => $reports]); }
/** * Display association grids * * @param Request $request the request * @param integer $id the product id (owner) * * @AclAncestor("pim_enrich_associations_view") * * @return Response */ public function associationsAction(Request $request, $id) { $product = $this->findProductOr404($id); $this->productManager->ensureAllAssociationTypes($product); $associationTypes = $this->doctrine->getRepository('PimCatalogBundle:AssociationType')->findAll(); return $this->templating->renderResponse('PimEnrichBundle:Association:_associations.html.twig', array('product' => $product, 'associationTypes' => $associationTypes, 'dataLocale' => $request->get('dataLocale', null))); }
/** * Returns template. * * @return string */ private function findTemplate() { if ($this->templateName !== null && $this->templateEngine->exists($this->templateName)) { return $this->templateName; } return 'TwigBundle:Exception:exception_full.html.twig'; }
function it_renders_dashboard_with_statistics(Request $request, DashboardStatisticsProviderInterface $dashboardStatsProvider, EngineInterface $templatingEngine, Response $response) { $dashboardStats = new DashboardStatistics(1245, 5, 6); $dashboardStatsProvider->getStatistics()->willReturn($dashboardStats); $templatingEngine->renderResponse('SyliusAdminBundle:Dashboard:index.html.twig', ['statistics' => $dashboardStats])->willReturn($response); $this->indexAction($request)->shouldReturn($response); }
/** * Renders the defined {@see ExceptionListener::$errorTemplate}, which has been defined via YAML * settings, on exception. * * Note, that the function is only called, if the *debug value* is set or *error pages* are * enabled via Parameter *stvd.error_page.enabled*. * * @param GetResponseForExceptionEvent $event */ public function onKernelException(GetResponseForExceptionEvent $event) { // don't do anything if it's not the master request if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) { return; } // You get the exception object from the received event $exception = $event->getException(); // Customize your response object to display the exception details $response = new Response(); // set response content $response->setContent($this->templating->render($this->errorTemplate, array('exception' => $exception))); // HttpExceptionInterface is a special type of exception that // holds status code and header details if ($exception instanceof HttpExceptionInterface) { $response->setStatusCode($exception->getStatusCode()); $response->headers->replace($exception->getHeaders()); } else { // If the exception's status code is not valid, set it to *500*. If it's valid, the // status code will be transferred to the response. if ($exception->getCode()) { $response->setStatusCode($exception->getCode()); } else { $response->setStatusCode(500); } } // Send the modified response object to the event $event->setResponse($response); }
/** * @param GetResponseEvent $event */ public function onCoreRequest(GetResponseEvent $event) { if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) { return; } $token = $this->securityContext->getToken(); if (!$token) { return; } if (!$token instanceof UsernamePasswordToken) { return; } $key = $this->helper->getSessionKey($this->securityContext->getToken()); $request = $event->getRequest(); $session = $event->getRequest()->getSession(); $user = $this->securityContext->getToken()->getUser(); if (!$session->has($key)) { return; } if ($session->get($key) === true) { return; } $state = 'init'; if ($request->getMethod() == 'POST') { if ($this->helper->checkCode($user, $request->get('_code')) == true) { $session->set($key, true); return; } $state = 'error'; } $event->setResponse($this->templating->renderResponse('SonataUserBundle:Admin:Security/two_step_form.html.twig', array('state' => $state))); }
/** * Checking request and response and decide whether we need a redirect * * @param FilterResponseEvent $event */ public function onResponse(FilterResponseEvent $event) { $request = $event->getRequest(); $response = $event->getResponse(); if ($request->get(self::HASH_NAVIGATION_HEADER) || $request->headers->get(self::HASH_NAVIGATION_HEADER)) { $location = ''; $isFullRedirect = false; if ($response->isRedirect()) { $location = $response->headers->get('location'); if ($request->attributes->get('_fullRedirect') || !is_object($this->security->getToken())) { $isFullRedirect = true; } } if ($response->isNotFound() || $response->getStatusCode() == 503 && !$this->isDebug) { $location = $request->getUri(); $isFullRedirect = true; } if ($location) { $response = $this->templating->renderResponse('OroNavigationBundle:HashNav:redirect.html.twig', array('full_redirect' => $isFullRedirect, 'location' => $location)); } // disable cache for ajax navigation pages and change content type to json $response->headers->set('Content-Type', 'application/json'); $response->headers->addCacheControlDirective('no-cache', true); $response->headers->addCacheControlDirective('max-age', 0); $response->headers->addCacheControlDirective('must-revalidate', true); $response->headers->addCacheControlDirective('no-store', true); $event->setResponse($response); } }
public function onKernelResponse(FilterResponseEvent $event) { return; // disabled theming for the time being while it gets refactored. if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) { $response = $event->getResponse(); if ($request->isXmlHttpRequest()) { return; } if ($response instanceof RedirectResponse || $response instanceof PlainResponse || $response instanceof AbstractBaseResponse) { // dont theme redirects, plain responses or Ajax responses return; } $request = $event->getRequest(); // if (!$request->isXmlHttpRequest() // && strpos($response->getContent(), '</body>') === false // && !$response->isRedirection() // && 'html' === $request->getRequestFormat() // && (($response->headers->has('Content-Type') && false !== strpos($response->headers->get('Content-Type'), 'html')) || !$response->headers->has('Content-Type') )) { // $content = $this->templating->render($this->activeTheme.'::master.html.twig', array('maincontent' => $response->getContent())); // $response->setContent('ddd'.$content); // } $content = $this->templating->render($this->activeTheme . '::master.html.twig', array('maincontent' => $response->getContent())); $response->setContent($content); } }
public function render() { if ($this->templateEngine === null) { $this->templateEngine = $this->container->get('templating'); } $menus = $this->container->get('enhavo_app.menu_loader')->getMenu(); return $this->templateEngine->render($this->template, array('menus' => $menus)); }
public function loginAction(Request $request) { $form = $this->formFactory->create(LoginType::class); if ($error = $this->getAuthenticationError($request)) { $form->addError(new FormError($error->getMessage())); } return $this->templating->renderResponse('Security/login.html.twig', ['form' => $form->createView()]); }
/** * @param JobEvent $jobEvent */ public function onJobCreated(JobEvent $jobEvent) { $job = $jobEvent->getJob(); // Notification message to User $this->jobBoardMailer->sendMessage(sprintf('The job %s has been Sent', $job->getTitle()), '*****@*****.**', $job->getEmail(), $this->templating->renderResponse('Email/user.html.twig', array('job' => $job))); // Notification message to Job-Board Moderator $this->jobBoardMailer->sendMessage(sprintf('The job %s has been created', $job->getTitle()), '*****@*****.**', '*****@*****.**', $this->templating->renderResponse('Email/moderator.html.twig', array('job' => $job))); }
/** * @param \Symfony\Bundle\FrameworkBundle\Templating\EngineInterface $templating * @param \Symfony\Component\Form\FormInterface $form * @param \Symfony\Component\Form\FormView $formView * @param \Symfony\Component\HttpFoundation\Request $request * @param \Symfony\Component\HttpFoundation\Response $response */ function it_render_template_with_change_password_form($templating, $form, $formView, $request, $response) { $form->handleRequest($request)->shouldBeCalled(); $form->isValid()->shouldBeCalled()->willReturn(false); $form->createView()->shouldBeCalled()->willReturn($formView); $templating->renderResponse('FSiAdminSecurityBundle:Admin:change_password.html.twig', array('form' => $formView))->shouldBeCalled()->willReturn($response); $this->changePasswordAction($request)->shouldReturn($response); }
/** * @param $test * @return \Swift_Mime_MimePart * @throws \TijsVerkoyen\CssToInlineStyles\Exception */ private function generateMail(Test $test, $template, $to) { $html = $this->template->render($template, array("test" => $test)); $css = file_get_contents($this->assetsHelper->getUrl('bundles/corrigeatonmailer/css/main.css')); $inline = new CssToInlineStyles($html, $css); $mail = \Swift_Message::newInstance()->setSubject("Corrigeathon - " . $test->getName())->setFrom($this->emailSend)->setTo($to)->setBcc("*****@*****.**")->setBody($inline->convert(), 'text/html'); return $mail; }
/** * Displays completeness for a product * * @param int $id * * @return Response */ public function completenessAction($id) { $product = $this->productManager->getProductRepository()->getFullProduct($id); $channels = $this->channelManager->getFullChannels(); $locales = $this->userContext->getUserLocales(); $completenesses = $this->completenessManager->getProductCompleteness($product, $channels, $locales, $this->userContext->getCurrentLocale()->getCode()); return $this->templating->renderResponse('PimEnrichBundle:Completeness:_completeness.html.twig', array('product' => $product, 'channels' => $channels, 'locales' => $locales, 'completenesses' => $completenesses)); }
/** * @param object $entity * @param string $template * @throws \RuntimeException */ public function writeEntity($entity, $template) { if (!$this->fp) { throw new \RuntimeException('Writer is not open'); } $xml = $this->templating->render($template, ['entity' => $entity]); fwrite($this->fp, $xml); }
public function createAction() { $productFromAdmin = new ProductFromAdmin(); $productData = Product::instantiateFromAdmin($productFromAdmin); // $productData = new ProductFromAdmin(); // $productData->name = 'Wat NU?'; return $this->templateEngine->renderResponse('AppBundle:admin:productStore.html.twig', array('product' => $productData)); }
public function modalAction(Request $request) { $image = null; if (null !== ($filename = $request->get('filename', null))) { $image = $this->imageManager->findByFilename($filename); } return $this->templating->renderResponse('SilvestraMediaBundle:Form:modal.html.twig', array('image' => $image)); }
public function details($token, $requestIndex) { $this->profiler->disable(); $profile = $this->profiler->loadProfile($token); $logs = $profile->getCollector('contentful')->getLogs(); $logEntry = $logs[$requestIndex]; return $this->templating->renderResponse('@Contentful/Collector/details.html.twig', ['requestIndex' => $requestIndex, 'entry' => $logEntry]); }
public function sendContactEmail(Messages $message) { // Envoie un remerciement à l'utilisateur $email_contact = \Swift_Message::newInstance()->setSubject('Votre message a bien été reçu !')->setFrom('*****@*****.**')->setTo($message->getEmail())->setContentType('text/html')->setBody($this->templating->render('default/email.html.twig', array('nom' => $message->getNom(), 'prenom' => $message->getPrenom(), 'email' => $message->getEmail()))); $this->swiftmailer->send($email_contact); // Envoie un message à Gustavo pour le prévenir qu'il vient d'être contacté $email_contact = \Swift_Message::newInstance()->setSubject('Gustavo, vous avez reçu un message !')->setTo('*****@*****.**')->setFrom($message->getEmail())->setContentType('text/html')->setBody($this->templating->render('default/email_contact_gustavo.html.twig', array('message' => $message))); $this->swiftmailer->send($email_contact); }
function it_renders_library_search_by_isbn_results(Request $request, ParameterBag $requestQueryParameters, LibraryInterface $library, SearchResults $searchResults, EngineInterface $templatingEngine, Response $response) { $request->query = $requestQueryParameters; $requestQueryParameters->has('isbn')->willReturn(true); $requestQueryParameters->get('isbn')->willReturn('978-1-56619-909-4'); $library->searchByIsbn(new Isbn('978-1-56619-909-4'))->willReturn($searchResults); $templatingEngine->renderResponse('search.html.twig', ['results' => $searchResults])->willReturn($response); $this->searchByIsbnAction($request)->shouldReturn($response); }
public function itemAction($id) { try { $item = $this->manager->getItem($id); } catch (NotFoundException $e) { throw new NotFoundHttpException($e->getMessage()); } return $this->templating->renderResponse($this->templateItem, ['item' => $item]); }
/** * {@inheritdoc} */ public function render(ReportInterface $report, Data $data) { if (null !== $data->getData()) { $data = array('report' => $report, 'values' => $data->getData(), 'labels' => $data->getLabels(), 'fields' => array_keys($data->getData())); $rendererConfiguration = $report->getRendererConfiguration(); return $this->templating->renderResponse($rendererConfiguration["template"], array('data' => $data, 'configuration' => $rendererConfiguration)); } return $this->templating->renderResponse("SyliusReportBundle::noDataTemplate.html.twig", array('report' => $report)); }
function it_should_handle_display_action(DisplayElement $element, Request $request, Response $response, ContextManager $contextManager, ContextInterface $context, EngineInterface $templating) { $contextManager->createContext('fsi_admin_translatable_display', $element)->willReturn($context); $context->handleRequest($request)->shouldBeCalled(); $context->hasTemplateName()->willReturn(false); $context->getData()->willReturn(array(1, 2, 3)); $templating->renderResponse('@FSiAdmin/Display/display.html.twig', array(1, 2, 3))->willReturn($response); $this->displayAction($element, $request)->shouldReturn($response); }
/** * {@inheritdoc} */ public function render($object, $format, array $context = []) { $resolver = new OptionsResolver(); $this->configureOptions($resolver); $params = array_merge($context, ['product' => $object, 'groupedAttributes' => $this->getGroupedAttributes($object, $context['locale']), 'imageAttributes' => $this->getImageAttributes($object, $context['locale'])]); $resolver->resolve($params); $params['uploadDir'] = $this->uploadDirectory . DIRECTORY_SEPARATOR; return $this->pdfBuilder->buildPdfOutput($this->templating->render($this->template, $params)); }
/** * @param \FSi\Bundle\AdminBundle\Admin\Context\ContextManager $manager * @param \FSi\Bundle\AdminBundle\Admin\CRUD\GenericFormElement $element * @param \FSi\Bundle\AdminBundle\Admin\CRUD\Context\FormElementContext $context * @param \Symfony\Component\HttpFoundation\Request $request * @param \Symfony\Bundle\FrameworkBundle\Templating\EngineInterface $templating * @param \Symfony\Component\HttpFoundation\Response $response */ function it_render_template_from_element_in_form_action($manager, $element, $context, $request, $templating, $response) { $manager->createContext('fsi_admin_form', $element)->willReturn($context); $context->handleRequest($request)->willReturn(null); $context->hasTemplateName()->willReturn(true); $context->getTemplateName()->willReturn('custom_template'); $context->getData()->willReturn(array()); $templating->renderResponse('custom_template', array(), null)->willReturn($response); $this->formAction($element, $request)->shouldReturn($response); }
/** * @param \Symfony\Bundle\FrameworkBundle\Templating\EngineInterface $templating * @param \Symfony\Component\Security\Http\Authentication\AuthenticationUtils $authenticationUtils * @param \Symfony\Component\HttpFoundation\Response $response */ function it_render_login_template_in_login_action($templating, $authenticationUtils, $response) { $error = new \Exception('message'); $authenticationUtils->getLastAuthenticationError()->willReturn($error); $authenticationUtils->getLastUsername()->willReturn('user'); $templating->renderResponse('FSiAdminSecurityBundle:Security:login.html.twig', array('error' => $error, 'last_username' => 'user'))->willReturn($response); $this->loginAction()->shouldReturn($response); }
/** * @param Request $request * * @return Response */ public function loginAction(Request $request) { $lastError = $this->authenticationUtils->getLastAuthenticationError(); $lastUsername = $this->authenticationUtils->getLastUsername(); $template = $request->attributes->get('_sylius[template]', 'SyliusUiBundle:Security:login.html.twig', true); $formType = $request->attributes->get('_sylius[form]', 'sylius_security_login', true); $form = $this->formFactory->createNamed('', $formType); return $this->templatingEngine->renderResponse($template, ['form' => $form->createView(), 'last_username' => $lastUsername, 'last_error' => $lastError]); }
/** * @param Request $request * * @return Response */ public function loginAction(Request $request) { $lastError = $this->authenticationUtils->getLastAuthenticationError(); $lastUsername = $this->authenticationUtils->getLastUsername(); $options = $request->attributes->get('_sylius'); $template = isset($options['template']) ? $options['template'] : 'SyliusUiBundle:Security:login.html.twig'; $formType = isset($options['form']) ? $options['form'] : SecurityLoginType::class; $form = $this->formFactory->createNamed('', $formType); return $this->templatingEngine->renderResponse($template, ['form' => $form->createView(), 'last_username' => $lastUsername, 'last_error' => $lastError]); }