當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Application::setModule方法代碼示例

本文整理匯總了PHP中yii\base\Application::setModule方法的典型用法代碼示例。如果您正苦於以下問題:PHP Application::setModule方法的具體用法?PHP Application::setModule怎麽用?PHP Application::setModule使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yii\base\Application的用法示例。


在下文中一共展示了Application::setModule方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: bootstrap

 /**
  * @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);
     }
 }
開發者ID:fg,項目名稱:yii2-modular,代碼行數:34,代碼來源:Loader.php

示例2: bootstrap

 /**
  * 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()];
     }
 }
開發者ID:duvanskiy,項目名稱:yii2-deferred-tasks,代碼行數:14,代碼來源:Bootstrap.php

示例3: bootstrap

 /**
  * 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);
 }
開發者ID:rochdi80tn,項目名稱:yii2-pages-module,代碼行數:16,代碼來源:Bootstrap.php

示例4: bootstrap

 /**
  * 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);
 }
開發者ID:dmstr,項目名稱:yii2-pages-module,代碼行數:16,代碼來源:Bootstrap.php

示例5: bootstrap

 /**
  * 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']);
 }
開發者ID:iVovolk,項目名稱:yii2-deferred-tasks,代碼行數:16,代碼來源:Bootstrap.php

示例6: bootstrap

 /**
  * 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');
 }
開發者ID:febfeb,項目名稱:yii2-dynamic-field,代碼行數:9,代碼來源:Bootstrap.php

示例7: bootstrap

 /**
  * Register module as `packaii`
  *
  * @param \yii\base\Application $app
  */
 public function bootstrap($app)
 {
     if (!$app->hasModule('packaii')) {
         $app->setModule('packaii', ['class' => 'schmunk42\\packaii\\Module']);
     }
 }
開發者ID:NageshVeeravalli,項目名稱:yii2-packaii,代碼行數:11,代碼來源:Bootstrap.php


注:本文中的yii\base\Application::setModule方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。