コード例 #1
0
ファイル: AbstractPlugin.php プロジェクト: rafasashi/Phile
 /**
  * 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);
 }
コード例 #2
0
ファイル: Plugin.php プロジェクト: sturple/phileLess
 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');
 }