/** * Bootstrap method to be called during application bootstrap stage. * * @param Application $app the application currently running */ public function bootstrap($app) { if (!isset($app->get('i18n')->translations['roxy*'])) { $app->get('i18n')->translations['roxy*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages', 'sourceLanguage' => 'en-US']; } Yii::setAlias('roxymce', __DIR__); }
/** * Bootstrap method to be called during application bootstrap stage. * @param Application $app the application currently running */ public function bootstrap($app) { /** @var Module $module */ /** @var \yii\db\ActiveRecord $modelName */ if ($app->hasModule('activeuser') && ($module = $app->getModule('activeuser')) instanceof Module) { $this->_modelMap = array_merge($this->_modelMap, $module->modelMap); foreach ($this->_modelMap as $name => $definition) { $class = "inblank\\activeuser\\models\\" . $name; Yii::$container->set($class, $definition); $modelName = is_array($definition) ? $definition['class'] : $definition; $module->modelMap[$name] = $modelName; } if ($app instanceof ConsoleApplication) { $app->controllerMap['activeuser'] = ['class' => 'inblank\\activeuser\\commands\\DefaultController']; } else { // init user Yii::$container->set('yii\\web\\User', ['loginUrl' => ['/activeuser/account/login'], 'identityClass' => self::di('User')]); $configUrlRule = ['prefix' => $module->urlPrefix, 'rules' => defined('IS_BACKEND') ? $module->urlRulesBackend : $module->urlRulesFrontend]; if ($module->urlPrefix != 'activeuser') { $configUrlRule['routePrefix'] = 'activeuser'; } $app->urlManager->addRules([new GroupUrlRule($configUrlRule)], false); if (defined('IS_BACKEND')) { // is backend, and controller have other namespace $module->controllerNamespace = 'inblank\\activeuser\\controllers\\backend'; $module->frontendUrlManager = new yii\web\UrlManager(['baseUrl' => '/', 'enablePrettyUrl' => true, 'showScriptName' => false]); $configUrlRule['rules'] = $module->urlRulesFrontend; $module->frontendUrlManager->addRules([new GroupUrlRule($configUrlRule)], false); } } if (!isset($app->get('i18n')->translations['activeuser*'])) { $app->get('i18n')->translations['activeuser*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages']; } } }
/** * Bootstrap method to be called during application bootstrap stage. * @param Application $app the application currently running */ public function bootstrap($app) { if (!$app instanceof \yii\web\Application) { return; } if (!$app->has('backend')) { $app->set('backend', static::className()); } if ($app->get('backend') instanceof Component) { $app->on(\yii\web\Application::EVENT_BEFORE_ACTION, [self::className(), 'detectBackend']); } }
/** * Bootstrap method to be called during application bootstrap stage. * @param Application $app the application currently running */ public function bootstrap($app) { $app->i18n->translations['admin/export'] = ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => '@yz/admin/export/common/messages', 'sourceLanguage' => 'en-US']; if ($app instanceof \yii\console\Application) { if ($app->has('schedule')) { /** @var omnilight\scheduling\Schedule $schedule */ $schedule = $app->get('schedule'); // Place all your shedule command below $schedule->command('admin-export/export/process'); } } }
/** * Registers searchable types. * * @param Application $app */ public function registerSearchableTypes($app) { /** @var \im\search\components\SearchManager $searchManager */ $searchManager = $app->get('searchManager'); $searchManager->registerSearchableType(['class' => 'im\\search\\components\\service\\db\\IndexedSearchableType', 'type' => 'product', 'modelClass' => 'im\\catalog\\models\\Product']); // $searchManager->registerSearchableType([ // 'class' => 'im\search\components\service\db\SearchableType', // 'modelClass' => 'im\catalog\models\Product', // 'type' => 'product', // 'searchServiceId' => 'db' // ]); }
/** * Bootstrap method to be called during application bootstrap stage. * * @param Application $app the application currently running */ public function bootstrap($app) { if ($app instanceof yii\web\Application) { $app->on(Application::EVENT_BEFORE_REQUEST, function () use($app) { $app->request->attachBehavior('monsterRequest', 'DotPlant\\Monster\\behaviors\\MonsterRequest'); }); $app->on(Application::EVENT_BEFORE_ACTION, function () use($app) { /** @var Repository $repository */ $repository = $app->get('monsterRepository'); $repository->autoloadAssets(); }); } }
/** * Get workbench compoment * @param yii\base\Application $app * @return \johnitvn\workbench\Workbench|null return Workbench or null if working directory is not exist */ public static function getInstance(Application $app) { if (!$app->has("workbench")) { $workbench = new Workbench(); } else { $workbench = $app->get("workbench"); } if ($workbench->workingDir === null) { $workbench->workingDir = dirname(dirname(dirname(__DIR__))) . '/workbench'; } // If workbench workspace not exist. return null if (!file_exists($workbench->workingDir)) { return null; } return $workbench; }
/** * * @param \yii\base\Application $app */ public function bootstrap($app) { $dbs = ArrayHelper::getValue($app->params, 'mdm.logger.attach', 'db'); if (!empty($dbs)) { foreach ((array) $dbs as $db) { if (is_string($db) && strpos($db, '\\') === false) { $db = $app->get($db, false); } elseif (!$db instanceof Connection) { $db = Yii::createObject($db); } if ($db !== null) { $db->on(Connection::EVENT_BEGIN_TRANSACTION, ['mdm\\logger\\RecordLogger', 'begin']); $db->on(Connection::EVENT_COMMIT_TRANSACTION, ['mdm\\logger\\RecordLogger', 'commit']); $db->on(Connection::EVENT_ROLLBACK_TRANSACTION, ['mdm\\logger\\RecordLogger', 'rollback']); } } } }
/** * @param Application $app */ public function registerLayouts($app) { $layoutManager = $app->get('layoutManager'); $layoutManager->registerLayout(Yii::createObject(['class' => 'im\\cms\\components\\Layout', 'id' => 'main', 'name' => 'Main layout', 'default' => true, 'availableWidgetAreas' => [['class' => 'im\\cms\\components\\WidgetAreaDescriptor', 'code' => 'sidebar', 'title' => 'Sidebar'], ['class' => 'im\\cms\\components\\WidgetAreaDescriptor', 'code' => 'footer', 'title' => 'Footer']]])); $layoutManager->registerLayout(Yii::createObject(['class' => 'im\\cms\\components\\Layout', 'id' => 'home', 'name' => 'Home', 'availableWidgetAreas' => [['class' => 'im\\cms\\components\\WidgetAreaDescriptor', 'code' => 'footer', 'title' => 'Footer']]])); }
/** * Registers search service. * * @param \yii\base\Application $app */ public function registerSearchService($app) { /** @var \im\search\components\SearchManager $searchManager */ $searchManager = $app->get('searchManager'); $searchManager->registerSearchService('db', ['class' => 'im\\search\\components\\service\\db\\SearchService', 'name' => 'Database']); }
/** * Bootstrap method to be called during application bootstrap stage. * @param Application $app the application currently running */ public function bootstrap($app) { /** @var Module $module */ if (($module = $app->getModule('admin')) == null || !$module instanceof Module) { return; } $class = 'nullref\\admin\\models\\Admin'; $definition = $module->adminModel; if ($module->enableRbac) { $module->setComponents(['authManager' => $module->authManager, 'roleContainer' => $module->roleContainer]); } Yii::$container->set($class, $definition); $className = is_array($definition) ? $definition['class'] : $definition; Event::on(AdminQuery::className(), AdminQuery::EVENT_INIT, function (Event $e) use($class, $className) { if ($e->sender->modelClass == $class) { $e->sender->modelClass = $className; } }); /** I18n */ if (!isset($app->get('i18n')->translations['admin*'])) { $app->i18n->translations['admin*'] = ['class' => PhpMessageSource::className(), 'basePath' => '@nullref/admin/messages']; } if ($app instanceof WebApplication) { Yii::$app->setComponents(['admin' => ['class' => 'nullref\\admin\\components\\User', 'identityClass' => $className, 'loginUrl' => ['admin/login']]]); $app->urlManager->addRules(['/admin/login' => '/admin/main/login']); $app->urlManager->addRules(['/admin/logout' => '/admin/main/logout']); Event::on(BaseModule::className(), BaseModule::EVENT_BEFORE_ACTION, function () use($module) { if (Yii::$app->controller instanceof IAdminController) { /** @var Controller $controller */ $controller = Yii::$app->controller; $controller->layout = $module->layout; if ($controller->module != $module) { $controller->module->setLayoutPath($module->getLayoutPath()); } if (!isset($controller->behaviors()['access'])) { $controller->attachBehavior('access', AccessControl::className()); } Yii::$app->errorHandler->errorAction = $module->errorAction; } }); } elseif ($app instanceof ConsoleApplication) { if ($module !== null) { /** @var Module $module */ if ($module->enableRbac) { $module->controllerMap['rbac'] = ['class' => 'nullref\\admin\\console\\RbacController']; } } } Event::on(Module::className(), Module::EVENT_BEFORE_INIT, function (Event $event) use($app) { $module = $event->sender; /** @var Module $module */ if ($module->enableRbac) { if ($app instanceof ConsoleApplication) { $module->controllerMap['rbac'] = ['class' => 'nullref\\admin\\console\\RbacController']; } $module->setComponents(['authManager' => $module->authManager, 'roleContainer' => $module->roleContainer]); } }); if (YII_ENV_DEV && class_exists('yii\\gii\\Module')) { Event::on(Gii::className(), Gii::EVENT_BEFORE_ACTION, function (Event $event) { /** @var Gii $gii */ $gii = $event->sender; $gii->generators['crud'] = ['class' => 'yii\\gii\\generators\\crud\\Generator', 'templates' => ['admin-crud' => '@nullref/admin/generators/crud/admin']]; $gii->generators['stuff'] = ['class' => 'nullref\\admin\\generators\\stuff\\Generator', 'templates' => ['default' => '@nullref/admin/generators/stuff/default']]; }); } }
/** * Registers search service. * * @param Application $app */ public function registerSearchService($app) { /** @var \im\search\components\SearchManager $searchManager */ $searchManager = $app->get('searchManager'); $searchManager->registerSearchService('elastic', ['class' => 'im\\elasticsearch\\components\\SearchService', 'name' => 'ElasticSearch']); }
/** * Registers widgets. * * @param Application $app */ public function registerWidgets($app) { $layoutManager = $app->get('layoutManager'); $layoutManager->registerWidget('im\\cms\\models\\widgets\\ContentWidget'); $layoutManager->registerWidget('im\\cms\\models\\widgets\\BannerWidget'); }