addParameters() public méthode

Adds a hash of parameters to the existing parameters.
public addParameters ( array $parameters )
$parameters array
 /**
  * Displays contact form and sends e-mail message when using POST request.
  *
  * @param \eZ\Publish\Core\MVC\Symfony\View\View $view
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \eZ\Publish\Core\MVC\Symfony\View\View|\Symfony\Component\HttpFoundation\Response
  */
 public function showContactFormAction(View $view, Request $request)
 {
     $form = $this->form->getForm();
     if ($request->isMethod('POST')) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             // sends e-mail using submitted data
             $sendingStatus = $this->sender->send($form->getData(), $this->emailTitle, $this->senderEmail, $this->recipientEmail);
             if ($sendingStatus) {
                 // redirects user to confirmation page after successful sending of e-mail
                 return new RedirectResponse($this->router->generate('app.submitted'));
             }
         }
     }
     $view->addParameters(['form' => $form->createView()]);
     return $view;
 }
 /**
  * Displays contact form and sends e-mail message when using POST request.
  *
  * @param \eZ\Publish\Core\MVC\Symfony\View\View $view
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \eZ\Publish\Core\MVC\Symfony\View\View|\Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function showContactFormAction(View $view, Request $request)
 {
     $form = $this->formFactory->create(ContactType::class);
     if ($request->isMethod('POST')) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $contact = $form->getData();
             try {
                 $this->sender->send($contact);
                 // redirects user to confirmation page after successful sending of e-mail
                 return new RedirectResponse($this->router->generate('app.submitted'));
             } catch (\Exception $e) {
                 //Todo add flash message to notify the user
             }
         }
     }
     $view->addParameters(['form' => $form->createView()]);
     return $view;
 }
 /**
  * Renders article with extra parameters that controls page elements visibility such as image and summary.
  *
  * @param \eZ\Publish\Core\MVC\Symfony\View\View $view
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function showArticleAction(View $view)
 {
     $view->addParameters(['showSummary' => $this->container->getParameter('ezdemo.article.full_view.show_summary'), 'showImage' => $this->container->getParameter('ezdemo.article.full_view.show_image')]);
     return $view;
 }
Exemple #4
0
 /**
  * Renders passed ContentView object via the template engine.
  * If $view's template identifier is a closure, then it is called directly and the result is returned as is.
  *
  * @param \eZ\Publish\Core\MVC\Symfony\View\View $view
  * @param array $defaultParams
  *
  * @return string
  */
 public function renderContentView(View $view, array $defaultParams = array())
 {
     $defaultParams['viewbaseLayout'] = $this->viewBaseLayout;
     $view->addParameters($defaultParams);
     $this->eventDispatcher->dispatch(MVCEvents::PRE_CONTENT_VIEW, new PreContentViewEvent($view));
     $templateIdentifier = $view->getTemplateIdentifier();
     $params = $view->getParameters();
     if ($templateIdentifier instanceof \Closure) {
         return $templateIdentifier($params);
     }
     return $this->templateEngine->render($templateIdentifier, $params);
 }
 public function injectViewParameters(View $view, array $parameters)
 {
     $event = new FilterViewParametersEvent($view, $parameters);
     $this->eventDispatcher->dispatch(ViewEvents::FILTER_VIEW_PARAMETERS, $event);
     $view->addParameters($event->getViewParameters());
 }