当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::get方法代码示例

本文整理汇总了PHP中yii\base\Application::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::get方法的具体用法?PHP Application::get怎么用?PHP Application::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\base\Application的用法示例。


在下文中一共展示了Application::get方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: bootstrap

 /**
  * 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__);
 }
开发者ID:navatech,项目名称:yii2-roxymce,代码行数:12,代码来源:Bootstrap.php

示例2: bootstrap

 /**
  * 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'];
         }
     }
 }
开发者ID:inblank,项目名称:yii2-activeuser,代码行数:39,代码来源:Bootstrap.php

示例3: 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\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']);
     }
 }
开发者ID:mihaildev,项目名称:yii2-backend,代码行数:16,代码来源:Component.php

示例4: bootstrap

 /**
  * 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');
         }
     }
 }
开发者ID:omnilight,项目名称:yz2-admin-export,代码行数:16,代码来源:Bootstrap.php

示例5: registerSearchableTypes

 /**
  * 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'
     //        ]);
 }
开发者ID:xyxdasnjss,项目名称:imshop,代码行数:17,代码来源:Bootstrap.php

示例6: 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\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();
         });
     }
 }
开发者ID:DevGroup-ru,项目名称:dotplant-monster,代码行数:18,代码来源:ExtensionBootstrap.php

示例7: getInstance

 /**
  * 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;
 }
开发者ID:johnitvn,项目名称:yii2-workbench,代码行数:21,代码来源:Workbench.php

示例8: bootstrap

 /**
  *
  * @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']);
             }
         }
     }
 }
开发者ID:mdmsoft,项目名称:yii2-logger,代码行数:22,代码来源:Bootstrap.php

示例9: registerLayouts

 /**
  * @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']]]));
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:9,代码来源:Bootstrap.php

示例10: registerSearchService

 /**
  * 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']);
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:11,代码来源:Bootstrap.php

示例11: bootstrap

 /**
  * 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']];
         });
     }
 }
开发者ID:NullRefExcep,项目名称:yii2-admin,代码行数:71,代码来源:Bootstrap.php

示例12: registerSearchService

 /**
  * 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']);
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:11,代码来源:Bootstrap.php

示例13: registerWidgets

 /**
  * 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');
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:11,代码来源:Bootstrap.php


注:本文中的yii\base\Application::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。