本文整理汇总了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);
}
}
示例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()];
}
}
示例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);
}
示例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);
}
示例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']);
}
示例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');
}
示例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']);
}
}