/** * initialize plugins * * @throws Exception\PluginException */ protected function initializePlugins() { $loader = new PluginRepository(); if (isset($this->settings['plugins']) && is_array($this->settings['plugins'])) { $this->plugins = $loader->loadAll($this->settings['plugins']); } Event::triggerEvent('plugins_loaded', ['plugins' => $this->plugins]); // throw not earlier to have the error-handler plugin loaded // and initialized (by 'plugins_loaded' event) $errors = $loader->getLoadErrors(); if (count($errors) > 0) { throw new PluginException($errors[0]['message'], $errors[0]['code']); } // settings now include initialized plugin-configs $this->settings = Registry::get('Phile_Settings'); Event::triggerEvent('config_loaded', ['config' => $this->settings]); }
/** * initialize template engine */ protected function initializeTemplate() { /** * @triggerEvent before_init_template this event is triggered before the template engine is init */ Event::triggerEvent('before_init_template'); $templateEngine = ServiceLocator::getService('Phile_Template'); /** * @triggerEvent before_render_template this event is triggered before the template is rendered * * @param \Phile\ServiceLocator\TemplateInterface the template engine */ Event::triggerEvent('before_render_template', array('templateEngine' => &$templateEngine)); $templateEngine->setCurrentPage($this->page); $output = $templateEngine->render(); /** * @triggerEvent after_render_template this event is triggered after the template is rendered * * @param \Phile\ServiceLocator\TemplateInterface the template engine * @param string the generated ouput */ Event::triggerEvent('after_render_template', array('templateEngine' => &$templateEngine, 'output' => &$output)); $this->response->setBody($output); }