public function rssAction($uri = null) { if (null === $this->application) { throw new FrontControllerException('A valid BackBee application is required.', FrontControllerException::INTERNAL_ERROR); } if (false === $this->application->getContainer()->has('site')) { throw new FrontControllerException('A BackBee\\Site instance is required.', FrontControllerException::INTERNAL_ERROR); } $site = $this->application->getContainer()->get('site'); if (false !== ($ext = strrpos($uri, '.'))) { $uri = substr($uri, 0, $ext); } if ('_root_' == $uri) { $page = $this->application->getEntityManager()->getRepository('BackBee\\NestedNode\\Page')->getRoot($site); } else { $page = $this->application->getEntityManager()->getRepository('BackBee\\NestedNode\\Page')->findOneBy(array('_site' => $site, '_url' => '/' . $uri, '_state' => Page::getUndeletedStates())); } try { $this->application->info(sprintf('Handling URL request `rss%s`.', $uri)); $response = new Response($this->application->getRenderer()->render($page, 'rss', null, 'rss.phtml', false)); $response->headers->set('Content-Type', 'text/xml'); $response->setClientTtl(15); $response->setTtl(15); $this->send($response); } catch (\Exception $e) { $this->defaultAction('/rss/' . $uri); } }
/** * Custom method to tell Renderer where to go for retrieving ToolbarBundle's views directory * * @param BBApplication $application * @param Config $config */ public static function loadTemplates(BBApplication $application, Config $config) { $viewsDir = __DIR__ . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . 'views'; if (!is_dir($viewsDir)) { $application->error("Unable to load ToolbarBundle views directory (:{$viewsDir})"); } else { $application->getRenderer()->addScriptDir($viewsDir); } }
public function __construct(BBApplication $application) { $this->application = $application; $this->renderer = $application->getRenderer(); $this->response = new Response(); }