/** * {@inheritdoc} */ public function bootstrap($app) { if ($this->_isBootstrapped) { return; } $this->_isBootstrapped = true; $this->_app = $app; if ($this->cache) { Yii::trace('Bootstrap from cache', get_called_class() . '::bootstrap'); $this->setItems($this->cache); // $this->toArray(); // TODO 2 SilverFire: check and remove this line } else { Yii::trace('Bootstrap plugins from the list of extensions', get_called_class() . '::bootstrap'); foreach ($app->extensions as $name => $extension) { foreach ($extension['alias'] as $alias => $path) { $class = strtr(substr($alias, 1) . '/' . 'Plugin', '/', '\\'); if (!class_exists($class)) { continue; } $ref = new ReflectionClass($class); if ($ref->isSubclassOf('hiqdev\\pluginmanager\\Plugin')) { $plugin = Yii::createObject($class); if ($plugin instanceof BootstrapInterface) { $plugin->bootstrap($app); } //$this->setPlugins([$name => $plugin]); $this->mergeItems($plugin->getItems()); } } } $this->saveCache($this->getItems()); } if ($this->aliases) { $app->setAliases($this->aliases); } if ($this->modules) { $modules = ArrayHelper::getItems($app->modules, array_keys($this->modules)); $this->modules = ArrayHelper::merge($this->modules, $modules); $app->setModules($this->modules); } if ($this->components) { $components = ArrayHelper::getItems($app->components, array_keys($this->components)); $this->components = ArrayHelper::merge($this->components, $components); $app->setComponents($this->components); } if ($app->has('menuManager')) { $app->menuManager->bootstrap($app); } if ($app->has('themeManager')) { $app->themeManager->bootstrap($app); } }
/** * Get specified items as array. * * @param mixed $keys specification * * @return array list of items */ public function getItems($keys = null) { return ArrayHelper::getItems($this->_items, $keys); }