コード例 #1
0
 private function getPageArray($page)
 {
     $site = $this->getSite();
     $twig = new \Twig_Environment(new \Twig_Loader_String());
     $twig->addExtension(new \Symfony\Bridge\Twig\Extension\HttpKernelExtension($this->get('fragment.handler')));
     $rendered = '';
     $rendered = $twig->render($page->getContent(), array());
     $page->setContent($rendered);
     $template = $this->getTemplate($site['code'], 'default');
     if (!($templateName = $page->getTemplate())) {
         //echo '<pre>' . print_r('не было шаблона', true) . '</pre>';
         $page->setTemplate($template);
     } else {
         $page->setTemplate($this->getTemplate($site['code'], $templateName));
     }
     /**
      * Рендерим контент страницы
      */
     $twig = new \Twig_Environment(new \Twig_Loader_String());
     $twig->addExtension(new \Symfony\Bridge\Twig\Extension\HttpKernelExtension($this->get('fragment.handler')));
     $rendered = $twig->render($page->getContent(), array());
     //echo '<pre>' . print_r($page->getTitle(), true) . '</pre>'; exit;
     $new_page = new Page();
     $new_page->setContent($rendered);
     $new_page->setController($page->getController());
     $new_page->setDescription($page->getDescription());
     $new_page->setHeader($page->getHeader());
     $new_page->setName($page->getName());
     $new_page->setUrl($page->getUrl());
     $new_page->setTitle($page->getTitle());
     $new_page->setTemplate($page->getTemplate());
     $new_page->setRoot($page->getRoot());
     return $new_page;
 }