operation_mode = $config['operation_mode']; } } /** * Defines necessary event listeners. */ public function run() { $dispatcher = EventDispatcher::getInstance(); $dispatcher->attachListener(Events::PAGE_ADD_JS, $this, 'addJs'); $dispatcher->attachListener(Events::PAGE_ADD_CSS, $this, 'addCss'); } /** * Adds custom JS file to the page. * * @see \Mibew\EventDispatcher\Events::PAGE_ADD_JS */ public function addJs(&$args) { if (preg_match('/^\/chat(\/\d{1,10}\/\d{1,10})?$/', $args['request']->getPathInfo())) { $args['js'][] = $this->getFilesPath() . '/js/' . $this->operation_mode . '.js'; $args['js'][] = $this->getFilesPath() . '/js/big_close_button.js'; } } /** * Adds custom CSS file to the page. * * @see \Mibew\EventDispatcher\Events::PAGE_ADD_CSS */ public function addCss(&$args) { if (preg_match('/^\/chat(\/\d{1,10}\/\d{1,10})?$/', $args['request']->getPathInfo())) { $args['css'][] = $this->getFilesPath() . '/css/big_close_button.css'; } } /** * Returns verision of the plugin. * * @return string Plugin's version. */ public static function getVersion() { return '0.0.1'; } }