/** * Render * * @throws Exception */ public function render() { $content = ''; $this->callEvent($this->getModule(), 'preRender'); $theme = self::getTheme(); if ($this->isThemeEnabled() && $theme instanceof Theme) { $layout = new View(); $layout->setTemplate($theme->getLayout()); $layout->config = $this->getConfig(); $layout->request = $this->getRequest(); $layout->menus = $this->menus; $layout->theme = $theme; $layout->application = $this; $layout->content = $this->getContent(); $module = $this->getModule(); foreach ($module as $key => $value) { if ($key == 'content') { $layout->content .= $value; } else { if (isset($layout->{$key})) { throw new Exception('View is using a reserved variable ' . $key); } else { $layout->{$key} = $value; } } } $globals = self::getGlobals(); if ($globals) { foreach ($globals as $key => $value) { $layout->{$key} = $value; } } $content = $layout->render(); } else { $content = $this->getContent(); } echo $content; $this->callEvent($this->getModule(), 'postRender'); }