public function match(View $view) { if (!$view instanceof LocationValueView) { return false; } return $this->matchLocation($view->getLocation()); }
public function match(View $view) { if (!$view instanceof ContentValueView) { return false; } return $this->matchContentTypeId($view->getContent()->contentInfo->contentTypeId); }
/** * Returns a ContentView object corresponding to block found within $view, or null if not applicable. * * @param \eZ\Publish\Core\MVC\Symfony\View\View $view * * @return \eZ\Publish\Core\MVC\Symfony\View\ContentView */ public function getView(View $view) { if (!$view instanceof BlockView) { return null; } $block = $view->getBlock(); $legacyKernel = $this->getLegacyKernel(); $legacyBlockClosure = function (array $params) use($block, $legacyKernel) { return $legacyKernel->runCallback(function () use($block, $params) { $tpl = eZTemplate::factory(); /** * @var \eZObjectForwarder */ $funcObject = $tpl->fetchFunctionObject('block_view_gui'); if (!$funcObject) { return ''; } $children = array(); $funcObject->process($tpl, $children, 'block_view_gui', false, array('block' => array(array(eZTemplate::TYPE_ARRAY, new BlockAdapter($block)))), array(), '', ''); if (is_array($children) && isset($children[0])) { return ezpEvent::getInstance()->filter('response/output', $children[0]); } return ''; }, false); }; return new ContentView($legacyBlockClosure); }
/** * Matches the $view against a set of matchers. * * @param \EzSystems\EzSupportToolsBundle\View\SystemInfoView $view * * @return bool */ public function match(View $view) { if (!$view instanceof SystemInfoView) { return false; } return $this->toIdentifier($view->getInfo()) === $this->identifier; }
public function match(View $view) { if (!$view instanceof BlockValueView) { return false; } return isset($this->values[$view->getBlock()->id]); }
public function match(View $view) { if (!$view instanceof ContentView) { return false; } return isset($this->values[$view->getContent()->contentInfo->remoteId]); }
/** * Matches the $view against a set of matchers. * * @param \eZ\Publish\Core\MVC\Symfony\View\View $view * * @return bool */ public function match(View $view) { if (!$view instanceof TagValueView) { return false; } return isset($this->values[$view->getTag()->mainTagId]); }
public function match(View $view) { if (!$view instanceof LocationValueView) { return false; } return isset($this->values[$view->getLocation()->remoteId]); }
public function match(View $view) { if (!$view instanceof ContentValueView) { return false; } $contentType = $this->repository->getContentTypeService()->loadContentType($view->getContent()->contentInfo->contentTypeId); return isset($this->values[$contentType->identifier]); }
/** * Matches the $view against a set of matchers. * * @param \eZ\Publish\Core\MVC\Symfony\View\View $view * * @return bool */ public function match(View $view) { if (!$view instanceof TagValueView) { return false; } $keyword = $this->translationHelper->getTranslatedByMethod($view->getTag(), 'getKeyword'); return isset($this->values[$keyword]); }
public function match(View $view) { if (!$view instanceof LocationValueView) { return false; } $parent = $this->loadParentLocation($view->getLocation()->parentLocationId); return isset($this->values[$parent->getContentInfo()->contentTypeId]); }
/** * @param \eZ\Publish\Core\MVC\Symfony\View\View $view * * @return string */ public function render(View $view) { $this->eventDispatcher->dispatch(MVCEvents::PRE_CONTENT_VIEW, new PreContentViewEvent($view)); $templateIdentifier = $view->getTemplateIdentifier(); if ($templateIdentifier instanceof Closure) { return $templateIdentifier($view->getParameters()); } return $this->templateEngine->render($view->getTemplateIdentifier(), $view->getParameters()); }
public function match(View $view) { if ($view instanceof LocationValueView) { return $this->matchLocation($view->getLocation()); } if ($view instanceof ContentValueView) { return $this->matchContentInfo($view->getContent()->contentInfo); } return false; }
/** * Matches the $view against a set of matchers. * * @param \eZ\Publish\Core\MVC\Symfony\View\View $view * * @return bool */ public function match(View $view) { if (!$view instanceof TagValueView) { return false; } $tag = $view->getTag(); $parentTag = $this->tagsService->sudo(function (TagsService $tagsService) use($tag) { return $tagsService->loadTag($tag->parentTagId); }); return isset($this->values[$parentTag->remoteId]); }
public function match(View $view) { if (!$view instanceof ContentView) { return false; } $contentInfo = $view->getContent()->contentInfo; $section = $this->repository->sudo(function (Repository $repository) use($contentInfo) { return $repository->getSectionService()->loadSection($contentInfo->sectionId); }); return isset($this->values[$section->identifier]); }
/** * Matches the $view against a set of matchers. * * @param \eZ\Publish\Core\MVC\Symfony\View\View $view * * @return bool */ public function match(View $view) { if (!$view instanceof TagValueView) { return false; } $tag = $view->getTag(); $parentTag = $this->tagsService->sudo(function (TagsService $tagsService) use($tag) { return $tagsService->loadTag($tag->parentTagId); }); $keyword = $this->translationHelper->getTranslatedByMethod($parentTag, 'getKeyword'); return isset($this->values[$keyword]); }
/** * Returns a ContentView object corresponding to content info found within $view, or void if not applicable. * * @param \eZ\Publish\Core\MVC\Symfony\View\View $view * * @return \eZ\Publish\Core\MVC\Symfony\View\ContentView|void */ public function getView(View $view) { if (!$view instanceof ContentView) { return null; } $viewType = $view->getViewType(); $contentInfo = $view->getContent()->contentInfo; $legacyKernel = $this->getLegacyKernel(); $legacyContentClosure = function (array $params) use($contentInfo, $viewType, $legacyKernel) { return $legacyKernel->runCallback(function () use($contentInfo, $viewType, $params) { $tpl = eZTemplate::factory(); /** * @var \eZObjectForwarder */ $funcObject = $tpl->fetchFunctionObject('content_view_gui'); if (!$funcObject) { return ''; } // Used by XmlText field type if (isset($params['objectParameters'])) { if (isset($params['linkParameters']) && $params['linkParameters'] !== null) { $linkParameters = $params['linkParameters']; } $tpl->setVariable('object_parameters', $params['objectParameters'], 'ContentView'); } elseif (isset($params['embedParams'])) { if (isset($params['embedParams']['link'])) { $linkParameters = $params['embedParams']['link']; } if (isset($params['embedParams']['config'])) { $tpl->setVariable('object_parameters', $params['embedParams']['config'], 'ContentView'); } } // Convert link parameters to Legacy Stack format if (isset($linkParameters)) { $tpl->setVariable('link_parameters', $this->legalizeLinkParameters($linkParameters), 'ContentView'); } $children = array(); $funcObject->process($tpl, $children, 'content_view_gui', false, array('content_object' => array(array(eZTemplate::TYPE_ARRAY, eZContentObject::fetch($contentInfo->id))), 'view' => array(array(eZTemplate::TYPE_STRING, $viewType))), array(), '', ''); if (is_array($children) && isset($children[0])) { return ezpEvent::getInstance()->filter('response/output', $children[0]); } return ''; }, false); }; $this->decorator->setContentView(new ContentView($legacyContentClosure)); return $this->decorator; }
public function getView(View $view) { $viewType = $view->getViewType(); if ($viewType !== 'full') { return null; } if (!$view instanceof ContentValueView) { return null; } if ($view->getContent()->contentInfo->sectionId !== $this->premiumSectionId) { return null; } if ($this->subscriptionChecker->userIsSubscriber($this->repository->getCurrentUser())) { return null; } return new ContentView("eZDemoBundle:{$viewType}:premium_content.html.twig"); }
/** * 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; }
/** * Returns a ContentView object corresponding to location found within $view. * Will basically run content/view legacy module with appropriate parameters. * * @param \eZ\Publish\Core\MVC\Symfony\View\View $view * * @return \eZ\Publish\Core\MVC\Symfony\View\ContentView|void */ public function getView(View $view) { if (!$view instanceof ContentView || !$view->getLocation() instanceof APILocation) { return null; } $logger = $this->logger; $legacyHelper = $this->legacyHelper; $currentViewProvider = $this; $viewParameters = array(); $request = $this->getCurrentRequest(); if (isset($request)) { $viewParameters = $request->attributes->get('viewParameters', array()); } $viewType = $view->getViewType(); $location = $view->getLocation(); $legacyContentClosure = function (array $params) use($location, $viewType, $logger, $legacyHelper, $viewParameters, $currentViewProvider) { $content = isset($params['content']) ? $params['content'] : null; // Additional parameters (aka user parameters in legacy) are expected to be scalar foreach ($params as $paramName => $param) { if (!is_scalar($param)) { unset($params[$paramName]); if (isset($logger)) { $logger->notice("'{$paramName}' is not scalar, cannot pass it to legacy content module. Skipping.", array(__METHOD__)); } } } // viewbaseLayout is useless in legacy views unset($params['viewbaseLayout']); $params += $viewParameters; // Render preview or published view depending on context. if (isset($params['isPreview']) && $params['isPreview'] === true && $content instanceof APIContent) { return $currentViewProvider->renderPreview($content, $params, $legacyHelper); } else { return $currentViewProvider->renderPublishedView($location, $viewType, $params, $legacyHelper); } }; $this->decorator->setContentView(new ContentView($legacyContentClosure)); return $this->decorator; }
/** * 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); }
/** * Checks if $valueObject has a usable configuration for $viewType. * If so, the configuration hash will be returned. * $valueObject can be for example a Location or a Content object. * * @param \eZ\Publish\Core\MVC\Symfony\View\View $view * * @return array|null The matched configuration as a hash, containing template or controller to use, or null if not matched. */ public function match(View $view) { $viewType = $view->getViewType(); if (!isset($this->matchConfig[$viewType])) { return null; } if (!isset($this->alreadyMatched[$viewType])) { $this->alreadyMatched[$viewType] = new SplObjectStorage(); } // If we already matched, just returned the matched value. if (isset($this->alreadyMatched[$viewType][$view])) { return $this->alreadyMatched[$viewType][$view]; } foreach ($this->matchConfig[$viewType] as $configHash) { $hasMatched = true; $matcher = null; foreach ($configHash['match'] as $matcherIdentifier => $value) { $matcher = $this->getMatcher($matcherIdentifier); $matcher->setMatchingConfig($value); if (!$matcher->match($view)) { $hasMatched = false; } } if ($hasMatched) { return $this->alreadyMatched[$viewType][$view] = $configHash + array('matcher' => $matcher); } } return $this->alreadyMatched[$viewType][$view] = null; }
public function __construct(View $view) { $this->view = $view; parent::__construct(sprintf("No view template was set to render the view with the '%s' view type. Check your view configuration.", $view->getViewType())); }
/** * 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; }
public function injectViewParameters(View $view, array $parameters) { $event = new FilterViewParametersEvent($view, $parameters); $this->eventDispatcher->dispatch(ViewEvents::FILTER_VIEW_PARAMETERS, $event); $view->addParameters($event->getViewParameters()); }