mode = 'display'; if (isset($config['submode'])) { switch($config['submode']) { case 'block': $this->submode = 'block'; break; case 'inline': $this->submode = 'inline'; break; } } break; case 'none': $this->mode = 'none'; break; } } } /** * Defines necessary event listener. */ public function run() { $dispatcher = EventDispatcher::getInstance(); $dispatcher->attachListener('widgetResponseAlter', $this, 'refreshButton'); } /** * Returns verision of the plugin. * * @return string Plugin's version. */ public static function getVersion() { return '0.1.0'; } /** * Manage the button outlook. * * @param array $args Event data */ public function refreshButton(&$args) { $g = $args['asset_url_generator']; $args['response']['load']['refresh'] = $g->generate(str_replace(DIRECTORY_SEPARATOR, '/', $this->getFilesPath()) . '/js/refresh.js', AssetUrlGeneratorInterface::ABSOLUTE_URL); $args['response']['handlers'][] = 'refreshButton'; $args['response']['dependencies']['refreshButton'] = array('refresh'); $args['response']['data']['refreshButton'] = array('mode' => $this->mode, 'submode' => $this->submode); } }