private function execute() { if (method_exists($this->controller, 'before_filter')) { $this->controller->before_filter($this->route->getParameters()); } $action = $this->action; $this->controller->{$action}($this->route->getParameters()); //View displaying $render = $this->controller->getRender(); if ($render != "false") { Internationalization::init(); $twig_options = array('cache' => false, 'autoescape' => false, 'strict_variables' => true); $loader = new \Twig_Loader_Filesystem('../' . VIEW_DIR . strtolower($this->route->getController())); $twig = new \Twig_Environment($loader, $twig_options); $twig->addFilter("tr", new \Twig_Filter_Function("\\MicroMuffin\\Internationalization::translate")); $twig->addFilter("url", new \Twig_Filter_Function("\\MicroMuffin\\Tools::sanitizeForUrl")); $page = $twig->render(($render == "true" ? $this->action : $render) . ".html.twig", $this->controller->getVariables()); //Base layout execution and displaying $layout = $this->controller->getRenderLayout(); if ($layout != "false") { $loader = new \Twig_Loader_Filesystem('../' . VIEW_DIR . 'base'); $twig = new \Twig_Environment($loader, $twig_options); $twig->addFilter("tr", new \Twig_Filter_Function("\\MicroMuffin\\Internationalization::translate")); $twig->addFilter("url", new \Twig_Filter_Function("\\MicroMuffin\\Tools::sanitizeForUrl")); $base = new \BaseController(); $base->{$layout}(); $params = $base->getVariables(); $params = array_merge($params, $this->controller->getLayoutVariables()); $params['_page'] = $page; echo $twig->render($layout . ".html.twig", $params); } else { echo $page; } } }