renderResponse() public method

public renderResponse ( $view, array $parameters = [], Response $response = null )
$parameters array
$response Symfony\Component\HttpFoundation\Response
 /**
  * @Route("/sitemap.xml", name="sitemap_route", defaults={"_format"="xml"})
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function getSitemapAction()
 {
     /** @var PageEleveurBranch[] $pageEleveurBranchess */
     $pageEleveurBranches = $this->peBranchRepository->findAll();
     $this->logger->info('generation de la sitemap', ['count' => count($pageEleveurBranches)]);
     $this->logger->debug('contenu de la sitemap', ['pageEleveurBranches' => $pageEleveurBranches]);
     return $this->templating->renderResponse('sitemap.xml.twig', ['pageEleveurBranches' => $pageEleveurBranches]);
 }
 /**
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function success(Request $request)
 {
     $id = $request->get('id');
     $charged = $request->get('charged');
     $created = $request->get('created');
     $currency = $request->get('currency');
     return $this->templating->renderResponse($this->stripeParameters['success_template'], ['id' => $id, 'charged' => $charged, 'created' => $created, 'currency' => $currency]);
 }
 /**
  * Renders top menu with child items.
  *
  * @param string $template
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function getChildNodesAction($template)
 {
     $locationSearchResults = $this->searchService->findLocations($this->menuQueryType->getQuery());
     $menuItems = [];
     foreach ($locationSearchResults->searchHits as $hit) {
         $menuItems[] = $hit->valueObject;
     }
     return $this->templating->renderResponse($template, ['menuItems' => $menuItems], new Response());
 }
 /**
  * Renders top menu with child items.
  *
  * @param string $template
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function getChildNodesAction($template)
 {
     $query = new LocationQuery();
     $query->query = $this->menuCriteria->generateChildCriterion($this->locationService->loadLocation($this->topMenuLocationId), $this->configResolver->getParameter('languages'));
     $query->sortClauses = [new SortClause\Location\Priority(LocationQuery::SORT_ASC)];
     $query->performCount = false;
     $content = $this->searchService->findLocations($query);
     $menuItems = [];
     foreach ($content->searchHits as $hit) {
         $menuItems[] = $hit->valueObject;
     }
     return $this->templating->renderResponse($template, ['menuItems' => $menuItems], new Response());
 }
 /**
  * @param Operation $operation
  * @return \Symfony\Component\HttpFoundation\Response
  * @throws \Exception
  */
 public function readAction(Operation $operation)
 {
     $newsItem = $this->contentService->getNewsItemByOperation($operation);
     $activity = $operation->getActivity();
     $locationModuleIdentifier = $activity->getLocation()->getLocationModule()->getIdentifier();
     $isCompanyPageShare = 'campaignchain-linkedin-page' == $locationModuleIdentifier;
     $isLive = true;
     if (!$newsItem->getLinkedinData()) {
         $connection = $this->restClient->getConnectionByActivity($activity);
         /*
          * Below calls to the Linkedin REST API will throw errors if the
          * Linkedin App has not been approved by Linkedin as part of their
          * partner program.
          */
         try {
             if ($isCompanyPageShare) {
                 $response = $connection->getCompanyUpdate($activity, $newsItem);
             } else {
                 $response = $connection->getUserUpdate($activity, $newsItem);
             }
             if (!is_null($response)) {
                 $newsItem->setLinkedinData($response);
                 $this->em->persist($newsItem);
                 $this->em->flush();
             } else {
                 $isLive = false;
             }
         } catch (\Exception $e) {
             $isLive = true;
         }
     }
     return $this->templating->renderResponse('CampaignChainOperationLinkedInBundle::read.html.twig', array('page_title' => $activity->getName(), 'news_item' => $newsItem, 'activity' => $activity, 'is_live' => $isLive, 'is_company' => $isCompanyPageShare));
 }
 /**
  * @Route("/contact/confirmation", name="confirmation_contact_route")
  *
  * La confirmation sur une URL différente permet à l'utilisateur de 'back'
  * pour refaire une demande de contact
  */
 public function confirmationAction()
 {
     $email = $this->session->getFlashBag()->get(static::FLASH_BAG_EMAIL);
     if (empty($email)) {
         return new RedirectResponse($this->router->generate('contact_route'));
     }
     return $this->templating->renderResponse('base.html.twig', [TwigNodeTemplateTreeSection::TEMPLATE_TREE_BRANCH => 'contact/confirmation', 'email' => $email[0]]);
 }
 /**
  * @Route("/elevage/{pageEleveurSlug}", name="getPageEleveur_route")
  * @Method("GET")
  *
  * @param $pageEleveurSlug
  * @param Request $request
  * @return RedirectResponse|Response
  */
 public function getAction($pageEleveurSlug, Request $request)
 {
     $pageEleveur = $this->pageEleveurService->findBySlug($pageEleveurSlug);
     if (!$pageEleveur) {
         throw new NotFoundHttpException(null, null);
     }
     /** @var AnonymousToken $token */
     $token = $this->tokenStorage->getToken();
     /** @var User $user */
     $user = $token->getUser();
     $isOwner = $user !== 'anon.' && $pageEleveur->getOwner()->getId() === $user->getId();
     $isPreview = $request->query->has('preview');
     if ($isPreview && !$isOwner) {
         $this->logger->notice('Requete visiteur sur page eleveur en mode preview', ['user' => $user, 'pageEleveurSlug' => $pageEleveurSlug, 'pageEleveurId' => $pageEleveur->getId()]);
         return new RedirectResponse($this->router->generate('getPageEleveur_route', ['pageEleveurSlug' => $pageEleveurSlug]));
     }
     return $this->templating->renderResponse('base.html.twig', [TwigNodeTemplateTreeSection::TEMPLATE_TREE_BRANCH => 'editable/page-eleveur', 'pageEleveur' => $pageEleveur, 'isEditable' => $isOwner && !$isPreview]);
 }
 public function sendHtmlEmail(array $from, array $to, $subject, $bodyHtml, array $additionalHeaders = array())
 {
     //
     $email = static::buildBaseEmail($from, $to, $subject, $additionalHeaders);
     // If the given body is a TemplatedEmailBody object, populate and reassign the string value to itself
     if ($bodyHtml instanceof TemplatedEmailBody) {
         $bodyHtml = $this->templating->renderResponse($bodyHtml->getTemplateName(), $bodyHtml->getVariables())->getContent();
     }
     $email->setHtml($bodyHtml);
     return $this->processResponse($this->sendGrid->web->send($email));
 }
 /**
  * @Route("/animal/{pageAnimalId}", name="getPageAnimal_route")
  * @Method("GET")
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function getAction($pageAnimalId)
 {
     $pageAnimal = $this->pageAnimalService->find($pageAnimalId);
     if (!$pageAnimal) {
         throw new NotFoundHttpException(null, null);
     }
     /** @var AnonymousToken $token */
     $token = $this->tokenStorage->getToken();
     /** @var User $user */
     $user = $token->getUser();
     $isOwner = $user !== 'anon.' && $pageAnimal->getOwner()->getId() === $user->getId();
     $pageEleveur = $this->pageEleveurService->findByPageAnimal($pageAnimal);
     return $this->templating->renderResponse('base.html.twig', [TwigNodeTemplateTreeSection::TEMPLATE_TREE_BRANCH => 'editable/page-animal', 'pageAnimal' => $pageAnimal, 'isEditable' => $isOwner, 'pageEleveur' => $pageEleveur]);
 }
Beispiel #10
0
 /**
  * @Route("/", name="teaser_route")
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
  * @throws \Exception
  */
 public function teaserAction(Request $request)
 {
     /** @var AnonymousToken $token */
     $token = $this->tokenStorage->getToken();
     /** @var User $user */
     $user = $token->getUser();
     if ($user == 'anon.') {
         return $this->templating->renderResponse('base.html.twig', [TwigNodeTemplateTreeSection::TEMPLATE_TREE_BRANCH => 'home/teaser']);
     }
     $pageEleveur = $this->pageEleveurService->findByOwner($user);
     $form = $this->formFactory->createNamedBuilder('creation-page-eleveur')->add('nom', TextType::class, ['label' => 'Nom de l\'élevage'])->add('save', SubmitType::class, array('label' => 'Créer ma page éleveur'))->getForm();
     $form->handleRequest($request);
     if (!$form->isSubmitted() && $pageEleveur) {
         // un eleveur ne peux pas créer une 2eme page eleveur
         return $this->templating->renderResponse('base.html.twig', [TwigNodeTemplateTreeSection::TEMPLATE_TREE_BRANCH => 'home/eleveur', 'pageEleveur' => $pageEleveur]);
     }
     if ($form->isSubmitted() && $form->isValid()) {
         // traitement du formulaire de creation de page eleveur
         $nom = $form->getData()['nom'];
         try {
             $slug = $this->pageEleveurService->create($nom, $user)->getSlug();
             return new RedirectResponse($this->router->generate('getPageEleveur_route', ['pageEleveurSlug' => $slug]));
         } catch (HistoryException $e) {
             $this->logger->error($e->getMessage(), ['exception' => $e, 'user' => $user, 'nom' => $nom]);
             switch ($e->getCode()) {
                 case HistoryException::NOM_INVALIDE:
                     return new Response('Le nom "' . $nom . '" n\'est pas valide.', Response::HTTP_NOT_ACCEPTABLE);
                 case HistoryException::SLUG_DEJA_EXISTANT:
                     return new Response('Une page éleveur du même nom existe déjà.', Response::HTTP_CONFLICT);
                 case HistoryException::DEJA_OWNER:
                     return new Response('Vous avez déjà une page éleveur.', Response::HTTP_BAD_REQUEST);
             }
         }
     }
     // home d'un user connecté mais qui n'a pas de page eleveur
     return $this->templating->renderResponse('base.html.twig', [TwigNodeTemplateTreeSection::TEMPLATE_TREE_BRANCH => 'home/creation-page-eleveur', 'creationPageEleveur' => $form->createView()]);
 }
 /**
  * Respond to an exception with an error document wrapped in a Response.
  *
  * @param GetResponseForExceptionEvent $event
  */
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     $exception = $event->getException();
     // only intercept SwordController exceptions.
     if (!$this->controller[0] instanceof SwordController) {
         return;
     }
     if (!$exception instanceof SwordException) {
         return;
     }
     $this->logger->critical($exception->getMessage() . ' from ' . $this->requestStack->getCurrentRequest()->getClientIp());
     $response = $this->templating->renderResponse('AppBundle:Sword:error.xml.twig', array('error' => $exception));
     $response->headers->set('Content-Type', 'text/xml');
     $response->setStatusCode($exception->getStatusCode());
     $event->setResponse($response);
 }
 /**
  * @Route("/qui-sommes-nous", name="quisommesnous_route")
  */
 public function quiSommesNousAction()
 {
     return $this->templating->renderResponse('base.html.twig', [TwigNodeTemplateTreeSection::TEMPLATE_TREE_BRANCH => 'qui-sommes-nous']);
 }
 /**
  * @param Company $company
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function showAction(Company $company)
 {
     $this->blockManager->setDocument($company);
     return $this->templating->renderResponse($this->themeManager->locateTemplate('content/Company/default.html.twig'), ['company' => $company]);
 }
 /**
  * @param JobPosting $jobPosting
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function showAction(JobPosting $jobPosting)
 {
     $this->blockManager->setDocument($jobPosting);
     return $this->templating->renderResponse($this->themeManager->locateTemplate('content/JobPosting/default.html.twig'), ['jobPosting' => $jobPosting]);
 }
 /**
  * @param Taxonomy $taxonomy
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function showAction(Taxonomy $taxonomy)
 {
     $this->blockManager->setDocument($taxonomy);
     return $this->templating->renderResponse($this->themeManager->locateTemplate('content/Taxonomy/default.html.twig'), ['taxonomy' => $taxonomy]);
 }
 /**
  * @param Article $article
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function showAction(Article $article)
 {
     $this->blockManager->setDocument($article);
     return $this->templating->renderResponse($this->themeManager->locateTemplate('content/Article/default.html.twig'), ['article' => $article]);
 }
 /**
  * @param Event $event
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function showAction(Event $event)
 {
     $this->blockManager->setDocument($event);
     return $this->templating->renderResponse($this->themeManager->locateTemplate('content/Event/default.html.twig'), ['event' => $event]);
 }