/** * Bootstrap method to be called during application bootstrap stage. * @param \yii\web\Application $app the application currently running */ public function bootstrap($app) { $app->set($this->id, $this); Yii::$container->set('gromver\\models\\fields\\EditorField', ['controller' => 'grom/media/manager']); Yii::$container->set('gromver\\models\\fields\\MediaField', ['controller' => 'grom/media/manager']); Yii::$container->set('gromver\\modulequery\\ModuleQuery', ['cache' => $app->cache, 'cacheDependency' => new ExpressionDependency(['expression' => '\\Yii::$app->getModulesHash()'])]); Yii::$container->set('gromver\\platform\\frontend\\components\\MenuMap', ['cache' => $app->cache, 'cacheDependency' => Table::dependency(MenuItem::tableName())]); /** @var MenuManager $manager */ $manager = \Yii::createObject(MenuManager::className()); $rules = [$manager]; if (is_array($this->blockModules) && count($this->blockModules)) { $rules['grom/<module:(' . implode('|', $this->blockModules) . ')><path:(/.*)?>'] = 'grom/default/page-not-found'; //блокируем доступ к контент модулям напрямую } $app->urlManager->addRules($rules, false); //вставляем в начало списка $app->set('menuManager', $manager); ModuleQuery::instance()->implement('\\gromver\\platform\\common\\interfaces\\BootstrapInterface')->invoke('bootstrap', [$app]); }
/** * @return ModuleQuery|object * @throws \yii\base\InvalidConfigException */ private static function moduleQuery() { if (!isset(self::$_moduleQuery)) { self::$_moduleQuery = Yii::createObject(ModuleQuery::className()); } return self::$_moduleQuery; }
/** * @inheritdoc */ public function bootstrap($app) { $app->set($this->id, $this); Yii::$container->set('gromver\\models\\fields\\EditorField', ['controller' => 'grom/media/manager']); Yii::$container->set('gromver\\models\\fields\\MediaField', ['controller' => 'grom/media/manager']); Yii::$container->set('gromver\\modulequery\\ModuleQuery', ['cache' => $app->cache, 'cacheDependency' => new ExpressionDependency(['expression' => '\\Yii::$app->getModulesHash()'])]); Table::bootstrap(); ModuleQuery::instance()->implement('\\gromver\\platform\\common\\interfaces\\BootstrapInterface')->invoke('bootstrap', [$app]); }
protected function buildRules() { //нам нужно собрать все роутеры от модулей и вытащить из них инструкции по маршрутизации $routers = ModuleQuery::instance()->implement('\\gromver\\platform\\frontend\\interfaces\\MenuRouterInterface')->fetch('getMenuRouter'); // вытаскиваем инструкции из всех роутеров foreach ($routers as $routerClass) { $router = $this->getRouter($routerClass); foreach ($router->createUrlRules() as $rule) { @$rule['class'] or $rule['class'] = MenuUrlRuleCreate::className(); $rule['router'] = $router->className(); $this->_createUrlRules[] = Yii::createObject($rule); } foreach ($router->parseUrlRules() as $rule) { @$rule['class'] or $rule['class'] = MenuUrlRuleParse::className(); $rule['router'] = $router->className(); $this->_parseUrlRules[] = Yii::createObject($rule); } } }
public function actionIndex() { return $this->render('index', ['items' => ModuleQuery::instance()->implement('\\gromver\\platform\\backend\\interfaces\\DesktopInterface')->orderBy('desktopOrder')->fetch('getDesktopItem')]); }
/** * Lists all routers. * @return mixed */ public function actionRouters() { Yii::$app->grom->layout = 'modal'; $items = ModuleQuery::instance()->implement('\\gromver\\platform\\backend\\interfaces\\MenuRouterInterface')->orderBy('desktopOrder')->fetch('getMenuRoutes'); return $this->render('routers', ['items' => $items]); }
/** * @inheritdoc */ public static function index() { return Yii::$app->getModule(ModuleQuery::instance()->implement('\\gromver\\platform\\core\\modules\\search\\modules\\elastic\\Module')->find()[0])->elasticsearchIndex; }
/** * @inheritdoc */ public function bootstrap($application) { $this->documentClasses = array_merge($this->documentClasses, ModuleQuery::instance()->implement('gromver\\platform\\common\\interfaces\\SearchableInterface')->fetch('getDocumentClasses', [], ModuleQuery::AGGREGATE_MERGE)); ActiveDocument::watch($this->documentClasses); }
/** * Bootstrap method to be called during application bootstrap stage. * @param \yii\web\Application $app the application currently running */ public function bootstrap($app) { $app->set($this->id, $this); Yii::$container->set('gromver\\modulequery\\ModuleQuery', ['cache' => $app->cache, 'cacheDependency' => new ExpressionDependency(['expression' => '\\Yii::$app->getModulesHash()'])]); ModuleQuery::instance()->implement('\\gromver\\platform\\basic\\interfaces\\module\\BootstrapInterface')->invoke('bootstrap', [$app]); }
/** * @inheritdoc */ public function bootstrap($app) { $app->set($this->id, $this); $this->_moduleConfigDependency = new ExpressionDependency(['expression' => '\\Yii::$app->getModulesHash()']); DbState::bootstrap(); Yii::$container->set('gromver\\models\\fields\\EditorField', ['controller' => 'grom/media/manager', 'editorOptions' => ['filebrowserBrowseUrl' => ['/grom/menu/backend/item/ckeditor-select'], 'extraPlugins' => 'codesnippet']]); Yii::$container->set('gromver\\models\\fields\\MediaField', ['controller' => 'grom/media/manager']); Yii::$container->set('gromver\\modulequery\\ModuleQuery', ['cache' => $app->cache, 'cacheDependency' => $this->_moduleConfigDependency]); Yii::$container->set('gromver\\platform\\basic\\components\\MenuMap', ['cache' => $app->cache, 'cacheDependency' => DbState::dependency(MenuItem::tableName())]); Yii::$container->set('gromver\\platform\\basic\\components\\MenuUrlRule', ['cache' => $app->cache, 'cacheDependency' => $this->_moduleConfigDependency]); Yii::$container->set('gromver\\platform\\basic\\modules\\main\\widgets\\Desktop', ['cache' => $app->cache, 'cacheDependency' => $this->_moduleConfigDependency]); /** @var MenuManager $manager */ $rules['auth'] = 'grom/auth/default/login'; $rules['admin'] = 'grom/backend/default/index'; if (is_array($this->blockedUrlRules) && count($this->blockedUrlRules)) { foreach ($this->blockedUrlRules as $rule) { $rules[$rule] = 'grom/default/page-not-found'; //блокируем доступ напрямую } } $app->urlManager->addRules($rules, false); //вставляем в начало списка $app->set('menuManager', \Yii::createObject(MenuManager::className())); // пропускаем \gromver\models\fields\events\ListItemsEvent событие, через ModuleEvent - не факт, что нужно, но почему бы и нет Event::on('\\gromver\\models\\fields\\ListField', 'fetchItems', function ($event) { /** @var $event \gromver\models\fields\events\ListItemsEvent */ ModuleEvent::trigger(self::EVENT_FETCH_LIST_ITEMS, new ListItemsModuleEvent(['sender' => $event])); }); ModuleQuery::instance()->implement('\\gromver\\platform\\common\\interfaces\\BootstrapInterface')->invoke('bootstrap', [$app]); }