/** * @param \Twig_Environment $env * @param string $name * @param ReadNodeInterface $node * @param array $parameters * * @return string * @throws NonExistingAreaException */ public function renderArea(\Twig_Environment $env, $name, ReadNodeInterface $node, array $parameters = array()) { $area = $node->getArea($name); if (!$area instanceof ReadAreaInterface) { throw new NonExistingAreaException(); } $parameters = array('area' => $area, 'parameters' => $parameters, 'nodeId' => $node->getNodeId(), 'siteId' => $node->getSiteId(), '_locale' => $node->getLanguage()); return $env->render("OpenOrchestraFrontBundle:Node:area.html.twig", $parameters); }
/** * Update response headers * * @param Response $response * @param ReadNodeInterface $node * @param Request $request * * @return Response */ protected function updateNodeResponse(Response $response, ReadNodeInterface $node, Request $request) { $tagManager = $this->get('open_orchestra_base.manager.tag'); $cacheableManager = $this->get('open_orchestra_display.manager.cacheable'); $cacheTags = array($tagManager->formatNodeIdTag($node->getNodeId()), $tagManager->formatLanguageTag($node->getLanguage()), $tagManager->formatSiteIdTag($node->getSiteId())); $cacheableManager->addCacheTags($cacheTags); if ($this->has('esi') && $this->get('esi')->hasSurrogateCapability($request)) { $response = $cacheableManager->setResponseCacheParameters($response, $node->getMaxAge(), CacheableInterface::CACHE_PUBLIC, true); } else { $cacheInfo = $this->get('open_orchestra_front.manager.node_response_manager')->getNodeCacheInfo($node); $privacy = $cacheInfo['isPublic'] ? CacheableInterface::CACHE_PUBLIC : CacheableInterface::CACHE_PRIVATE; $response = $cacheableManager->setResponseCacheParameters($response, $cacheInfo['MaxAge'], $privacy); } return $response; }
/** * @param ReadSiteInterface $site * @param ReadNodeInterface $node * @param RouteCollection $routes */ protected function generateRoutesForNode(ReadSiteInterface $site, ReadNodeInterface $node, RouteCollection $routes) { /** @var ReadSiteAliasInterface $alias */ foreach ($site->getAliases() as $key => $alias) { $nodeLanguage = $node->getLanguage(); if ($nodeLanguage == $alias->getLanguage()) { $pattern = $this->generateRoutePattern($node); if ($alias->getPrefix()) { $pattern = $this->suppressDoubleSlashes($alias->getPrefix() . '/' . $pattern); } $scheme = $node->getScheme(); if (is_null($scheme) || SchemeableInterface::SCHEME_DEFAULT == $scheme) { $scheme = $alias->getScheme(); } $nodeId = $node->getNodeId(); $siteId = $site->getSiteId(); $domain = $alias->getDomain(); $route = $this->generateRoute($pattern, $nodeLanguage, $nodeId, $siteId, $key, $domain, $scheme); $routes->add($key . '_' . $node->getId(), $route); } } }