Example #1
0
 /**
  * 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);
 }