/** * method to render the page/template * * @return mixed|string */ public function render() { $engine = $this->getEngine(); $vars = $this->getTemplateVars(); Event::triggerEvent('template_engine_registered', ['engine' => &$engine, 'data' => &$vars]); return $this->_render($engine, $vars); }
/** * initialize plugin * * try to keep all initialization in one method to have a clean class * for the plugin-user * * @param string $pluginKey * @deprecated since 2015-04-24; will be declared 'final' */ public function initializePlugin($pluginKey) { /** * init $plugin property */ $this->plugin['key'] = $pluginKey; list($vendor, $name) = explode('\\', $this->plugin['key']); $DS = DIRECTORY_SEPARATOR; $this->plugin['dir'] = PLUGINS_DIR . $vendor . $DS . $name . $DS; /** * init events */ foreach ($this->events as $event => $method) { Event::registerEvent($event, $this); } /** * init plugin settings */ $defaults = Utility::load($this->getPluginPath('config.php')); if (empty($defaults) || !is_array($defaults)) { $defaults = []; } $globals = Registry::get('Phile_Settings'); if (!isset($globals['plugins'][$pluginKey])) { $globals['plugins'][$pluginKey] = []; } // settings precedence: global > default > class $this->settings = array_replace_recursive($this->settings, $defaults, $globals['plugins'][$pluginKey]); // backwards compatibility to Phile 1.4 $this->injectSettings($this->settings); $globals['plugins'][$pluginKey]['settings'] = $this->settings; Registry::set('Phile_Settings', $globals); }
public function __construct() { \Phile\Event::registerEvent('plugins_loaded', $this); \Phile\Core\Event::registerEvent('config_loaded', $this); $this->logger = (new \Phile\Plugin\Sturple\PhileLogger\Plugin($relDir = 'lib/cache/logs', $logLevel = 'debug', $options = array()))->getLogger(); $this->config = \Phile\Registry::get('Phile_Settings'); }
/** * set the raw data to parse * * @param string $rawData the raw data */ public function setRawData($rawData) { /** * @triggerEvent before_read_file_meta this event is triggered before the meta data readed and parsed * * @param string rawData the unparsed data * @param \Phile\Model\Meta meta the meta model */ Event::triggerEvent('before_read_file_meta', array('rawData' => &$rawData, 'meta' => &$this)); $this->parseRawData($rawData); /** * @triggerEvent after_read_file_meta this event is triggered after the meta data readed and parsed * * @param string rawData the unparsed data * @param \Phile\Model\Meta meta the meta model */ Event::triggerEvent('after_read_file_meta', array('rawData' => &$rawData, 'meta' => &$this)); }
/** * method to get content of page, this method returned the parsed content * * @return mixed */ public function getContent() { /** * @triggerEvent before_parse_content this event is triggered before the content is parsed * * @param string content the raw data * @param \Phile\Model\Page page the page model */ Event::triggerEvent('before_parse_content', array('content' => $this->content, 'page' => &$this)); $content = $this->parser->parse($this->content); /** * @triggerEvent after_parse_content this event is triggered after the content is parsed * * @param string content the parsed content * @param \Phile\Model\Page page the page model */ Event::triggerEvent('after_parse_content', array('content' => &$content, 'page' => &$this)); return $content; }