Inheritance: extends StructureBridge, implements Sulu\Component\Content\Compat\PageInterface
Exemplo n.º 1
0
 /**
  * renders content with the real website controller.
  *
  * @param PageBridge $content
  * @param bool       $partial
  *
  * @return string
  */
 public function render(PageBridge $content, $partial = false)
 {
     // set active theme
     $webspace = $this->webspaceManager->findWebspaceByKey($content->getWebspaceKey());
     $this->activeTheme->setName($webspace->getTheme()->getKey());
     // get controller and invoke action
     $request = new Request();
     $request->attributes->set('_controller', $content->getController());
     $controller = $this->controllerResolver->getController($request);
     // prepare locale for translator and request
     $request->setLocale($content->getLanguageCode());
     $localeBefore = $this->translator->getLocale();
     $this->translator->setLocale($content->getLanguageCode());
     $this->requestStack->push($request);
     /** @var Response $response */
     $response = $controller[0]->{$controller[1]}($content, true, $partial);
     // roll back
     $this->requestStack->pop();
     $this->translator->setLocale($localeBefore);
     return $response->getContent();
 }
Exemplo n.º 2
0
 /**
  * @param VisitorInterface $visitor
  * @param PageBridge $bridge
  * @param array $type
  * @param Context $context
  */
 public function doSerialize(VisitorInterface $visitor, PageBridge $bridge, array $type, Context $context)
 {
     $context->accept(['document' => $bridge->getDocument(), 'structure' => $bridge->getStructure()->getName()]);
 }
Exemplo n.º 3
0
 /**
  * @param Request $request
  * @param PageBridge $content
  *
  * @return Route
  */
 protected function getStructureRoute(Request $request, PageBridge $content)
 {
     return new Route($request->getPathInfo(), ['_controller' => $content->getController(), 'structure' => $content, 'partial' => $request->get('partial', 'false') === 'true']);
 }