コード例 #1
0
 /**
  * Dump the single error pages for a siteAlias given by $errorNode
  * 
  * @param ReadNodeInterface $errorNode
  * @param int               $aliasId
  * @param string            $siteId
  *
  * @return string
  */
 protected function dumpErrorPageForSiteAlias(ReadNodeInterface $errorNode, $aliasId, $siteId)
 {
     $url = $this->router->generate('open_orchestra_base_node_preview', array('token' => $this->encrypter->encrypt($errorNode->getId()), 'aliasId' => $aliasId));
     $filepath = $siteId . '/alias-' . $aliasId . '/' . $errorNode->getName() . '.html';
     $crawler = $this->client->request('GET', $url);
     $this->filesystem->dumpFile('web/' . $filepath, $crawler->html());
     return $filepath;
 }
 /**
  * @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);
 }
 /**
  * @param ReadNodeInterface $node
  *
  * @return array
  */
 protected function transformBlock(ReadNodeInterface $node)
 {
     $blocksData = array();
     /** @var ReadBlockInterface $block */
     foreach ($node->getAreas() as $area) {
         foreach ($area->getBlocks() as $block) {
             $searchable = $block->getAttribute('searchable');
             if (true === $searchable) {
                 $contentBlock = $this->displayBlockManager->toString($block);
                 if ('' !== $contentBlock) {
                     $blocksData[] = array('type' => $block->getComponent(), 'content' => $contentBlock);
                 }
             }
         }
     }
     return $blocksData;
 }
コード例 #4
0
 /**
  * @param ReadNodeInterface $node
  * @param array             $tree
  *
  * @return mixed
  */
 protected function getNodePosition(ReadNodeInterface $node, $tree)
 {
     $position = $node->getOrder();
     while (array_key_exists($position, $tree)) {
         $position++;
     }
     return $position;
 }
 /**
  * @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);
         }
     }
 }
コード例 #6
0
 /**
  * @param ReadNodeInterface $node
  *
  * @return string
  * @throws \OpenOrchestra\FrontBundle\Exception\NonExistingTemplateException
  */
 protected function getTemplate(ReadNodeInterface $node)
 {
     $site = $this->get('open_orchestra_model.repository.site')->findOneBySiteId($node->getSiteId());
     $template = $node->getTemplate();
     $templateSet = $site->getTemplateSet();
     $templateManager = $this->get('open_orchestra_front.manager.template');
     return $templateManager->getTemplate($template, $templateSet);
 }
コード例 #7
0
 /**
  * Get the last modification date of $node
  * 
  * @param ReadNodeInterface $node
  * 
  * @return string
  */
 protected function getLastModificationDate(ReadNodeInterface $node)
 {
     $lastmod = "?";
     if (($date = $node->getUpdatedAt()) instanceof \DateTime) {
         $lastmod = $date->format('Y-m-d');
     }
     return $lastmod;
 }
 /**
  * Browse the hole $node to calculate the general cache policy of the $node
  * according to the areas and blocks.
  * If a block is private, the hole $node becomes private
  * The Max-age of the node is the min of the Max-age of all blocks
  *
  * @param ReadNodeInterface $node
  *
  * @return array
  */
 public function getNodeCacheInfo(ReadNodeInterface $node)
 {
     return $this->getCacheInfoFromAreas($node->getAreas(), $node->getMaxAge());
 }