public function getFunctions() { // Creating the getResource function $getResource = new \Twig_SimpleFunction('getResource', function ($pageName, $resource, $themable) { return Paladin::getRootFolder() . self::getFile($pageName, $resource, $themable, "resources"); }); // Creating the addPanel function $addPanel = new \Twig_SimpleFunction('addPanel', function ($pageName, $panel, $themable, $args) { echo Paladin::getTwig()->render(self::getFile($pageName, $panel, $themable, "panels"), $args); }); // Returning an array of the functions return array($getResource, $addPanel); }
/** * Renders a page * * @param page * The page relative path * @param pageInstance * The page main class instance * @param args * The arguments of the page */ private function renderPage($pageInstance, $args) { // Sending the 'beforeDisplayed()' event to the page $pageInstance->beforeDisplayed(); // Creating the template path $templatePath = "/" . $pageInstance->getName() . "/" . $pageInstance->getMainPage(); // If the page instance is themable and the current theme contains the page if ($pageInstance->isThemable() && file_exists(Paladin::getThemeLoader()->getFolder() . "/" . Paladin::getThemeLoader()->getCurrentTheme() . $templatePath)) { // Setting the template path to the theme template path $templatePath = Paladin::getThemeLoader()->getFolder() . "/" . Paladin::getThemeLoader()->getCurrentTheme() . $templatePath; } else { // Setting the template path to the default path $templatePath = $this->folder . $templatePath; } // Rendering the page with Twig echo Paladin::getTwig()->render($templatePath, $pageInstance->constructTwigArray($args)); // Sending the 'afterDisplayed()' event to the page $pageInstance->afterDisplayed(); }