/**
  * @param ReadNodeInterface $node
  * @param array             $list
  *
  * @return array
  */
 protected function getChildren(ReadNodeInterface $node, $list)
 {
     $children = array();
     if (!empty($list[$node->getNodeId()]) && is_array($list[$node->getNodeId()])) {
         foreach ($list[$node->getNodeId()] as $child) {
             $position = $this->getNodePosition($child, $children);
             $children[$position] = $this->createTree($child, $list);
         }
     }
     $children = $this->sortArray($children);
     return $children;
 }
 /**
  * @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;
 }