/** * @param \yii\base\Application $app * @throws ModuleBootstrapException * @throws ModuleUndefinedClassException */ public function bootstrap($app) { $this->app = $app; $modules = array_diff(scandir($this->getModulesPath()), array('..', '.')); $modulesOrder = []; foreach ($modules as $module) { $className = 'modules\\' . $module . '\\Module'; if (!class_exists($className)) { throw new ModuleUndefinedClassException('Can\'t load module ' . $className); } $interfaces = class_implements($className); // since PHP 5.5 // if (!isset($interfaces[ModuleBootstrapInterface::class])) { if (!isset($interfaces['common\\interfaces\\ModuleBootstrapInterface'])) { throw new ModuleBootstrapException('Module ' . $className . ' must implement common\\ModuleBootstrapInterface interface'); } if (!$app->hasModule($module)) { $app->setModule($module, $className); } // configure some properties $config = $this->getConfig($module); $this->configure($config); $modulesOrder[$className] = isset($config['bootOrder']) ? (int) $config['bootOrder'] : self::BOOT_ORDER_DEFAULT; } asort($modulesOrder); foreach ($modulesOrder as $className => $order) { $className::bootstrap($app); } }
/** * Bootstrap method to be called during application bootstrap stage. * * @param Application $app the application currently running */ public function bootstrap($app) { if ($app instanceof \yii\console\Application) { // add deferred module $app->setModule('deferred', new DeferredTasksModule('deferred', $app)); // this will automatically add deferred controller to console app $app->controllerMap['deferred'] = ['class' => DeferredController::className()]; } }
/** * Bootstrap method to be called during application bootstrap stage. * * @param Application $app the application currently running */ public function bootstrap($app) { // register migration $app->params['yii.migrations'][] = '@vendor/dmstr/yii2-pages-module/migrations'; // register module if (!\Yii::$app->hasModule('pages')) { $app->setModule('pages', ['class' => 'dmstr\\modules\\pages\\Module']); } // provide default page url rule $app->urlManager->addRules(['<parentLeave:[a-zA-Z0-9_\\-\\.]*>/<pageName:[a-zA-Z0-9_\\-\\.]*>-<id:[0-9]*>' => 'pages/default/page', '<pageName:[a-zA-Z0-9_\\-\\.]*>-<id:[0-9]*>' => 'pages/default/page'], true); }
/** * Bootstrap method to be called during application bootstrap stage. * * @param Application $app the application currently running */ public function bootstrap($app) { // register migration $app->params['yii.migrations'][] = '@vendor/dmstr/yii2-pages-module/migrations'; // register module if (\Yii::$app->hasModule('pages') && !\Yii::$app->hasModule('treemanager')) { $app->setModule('treemanager', ['class' => 'kartik\\tree\\Module', 'layout' => '@admin-views/layouts/main', 'treeViewSettings' => ['nodeView' => '@vendor/dmstr/yii2-pages-module/views/treeview/_form', 'fontAwesome' => true]]); } // provide default page url rule $app->urlManager->addRules([['class' => PageUrlRule::className()], '<pagePath:[a-zA-Z0-9_\\-\\./\\+]*>/<pageSlug:[a-zA-Z0-9_\\-\\.]*>-<pageId:[0-9]*>' => 'pages/default/page', '<pageSlug:[a-zA-Z0-9_\\-\\.]*>-<pageId:[0-9]*>' => 'pages/default/page'], true); }
/** * Bootstrap method to be called during application bootstrap stage. * * @param Application $app the application currently running */ public function bootstrap($app) { if ($app instanceof \yii\console\Application) { // add deferred module $app->setModule('deferred', new DeferredTasksModule('deferred', $app)); // this will automatically add deferred controller to console app $app->controllerMap['deferred'] = ['class' => DeferredController::className()]; } $app->i18n->translations['deferred-tasks'] = ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => __DIR__ . DIRECTORY_SEPARATOR . 'messages']; DeferredQueueEvent::on(DeferredController::className(), DeferredController::EVENT_DEFERRED_QUEUE_COMPLETE, [QueueCompleteEventHandler::className(), 'handleEvent']); }
/** * Bootstrap method to be called during application bootstrap stage. * * @param Application $app the application currently running */ public function bootstrap($app) { $app->setModule("dynamicfield", 'febfeb\\dynamicfield\\modules\\Module'); }
/** * Register module as `packaii` * * @param \yii\base\Application $app */ public function bootstrap($app) { if (!$app->hasModule('packaii')) { $app->setModule('packaii', ['class' => 'schmunk42\\packaii\\Module']); } }