本文整理汇总了PHP中yii\base\Application类的典型用法代码示例。如果您正苦于以下问题:PHP Application类的具体用法?PHP Application怎么用?PHP Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Application类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
*
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
\Yii::setAlias('@cornernote/dashboard', __DIR__);
if ($app->has('i18n')) {
$app->i18n->translations['dashboard'] = ['class' => 'yii\\i18n\\PhpMessageSource', 'sourceLanguage' => 'en', 'basePath' => '@cornernote/dashboard/messages'];
}
}
示例2: 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__);
}
示例3: attachEvents
/**
* Attaches global and class-level event handlers from sub-modules
*
* @param \yii\base\Application $app the application currently running
*/
public function attachEvents($app)
{
foreach ($this->getModules() as $moduleID => $config) {
$module = $this->getModule($moduleID);
if ($module instanceof EventManagerInterface) {
/** @var EventManagerInterface $module */
foreach ($module->attachGlobalEvents() as $eventName => $handler) {
$app->on($eventName, $handler);
}
foreach ($module->attachClassEvents() as $className => $events) {
foreach ($events as $eventName => $handlers) {
foreach ($handlers as $handler) {
if (is_array($handler) && is_callable($handler[0])) {
$data = isset($handler[1]) ? array_pop($handler) : null;
$append = isset($handler[2]) ? array_pop($handler) : null;
Event::on($className, $eventName, $handler[0], $data, $append);
} elseif (is_callable($handler)) {
Event::on($className, $eventName, $handler);
}
}
}
}
}
}
}
示例4: registryGenerators
/**
* Rook gii templates
*
* @param Application $app the application currently running
* @return array
*/
public function registryGenerators($app)
{
$gii = $app->getModule('gii');
if (!is_null($gii)) {
$gii->generators = ArrayHelper::merge($gii->generators, ['model' => ['class' => \yii\gii\generators\model\Generator::class, 'templates' => ['skeleton' => '@skeleton/gii/generators/model/skeleton']], 'crud' => ['class' => \yii\gii\generators\crud\Generator::class, 'templates' => ['skeleton' => '@skeleton/gii/generators/crud/skeleton']], 'controller' => ['class' => \yii\gii\generators\controller\Generator::class, 'templates' => ['skeleton' => '@skeleton/gii/generators/controller/skeleton']], 'form' => ['class' => \yii\gii\generators\form\Generator::class, 'templates' => ['skeleton' => '@skeleton/gii/generators/form/skeleton']], 'module' => ['class' => \skeleton\gii\generators\module\Generator::class, 'templates' => ['skeleton' => '@skeleton/gii/generators/module/skeleton']], 'extension' => ['class' => \yii\gii\generators\extension\Generator::class, 'templates' => ['skeleton' => '@skeleton/gii/generators/extension/skeleton']]]);
}
}
示例5: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
*
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
$app->i18n->translations['extensions-manager'] = ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => __DIR__ . DIRECTORY_SEPARATOR . 'messages'];
DeferredQueueEvent::on(DeferredController::className(), DeferredController::EVENT_DEFERRED_QUEUE_COMPLETE, [DeferredQueueCompleteHandler::className(), 'handleEvent']);
if ($app instanceof \yii\console\Application) {
$app->controllerMap['extension'] = ExtensionController::className();
$app->on(Application::EVENT_BEFORE_ACTION, function () {
$module = ExtensionsManager::module();
if ($module->autoDiscoverMigrations === true) {
if (isset(Yii::$app->params['yii.migrations']) === false) {
Yii::$app->params['yii.migrations'] = [];
}
/** @var array $extensions */
$extensions = $module->getExtensions();
foreach ($extensions as $name => $ext) {
if ($ext['composer_type'] === Extension::TYPE_DOTPLANT && $module->discoverDotPlantMigrations === false) {
continue;
}
$extData = ComposerInstalledSet::get()->getInstalled($ext['composer_name']);
$packageMigrations = ExtensionDataHelper::getInstalledExtraData($extData, 'migrationPath', true);
$packagePath = '@vendor/' . $ext['composer_name'];
foreach ($packageMigrations as $migrationPath) {
Yii::$app->params['yii.migrations'][] = "{$packagePath}/{$migrationPath}";
}
}
}
});
}
}
示例6: 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'];
}
}
}
示例7: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
*
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
/**
* @var Module $gii
*/
\Yii::setAlias('@carono', '@vendor/carono/yii2-components');
if ($app instanceof \yii\console\Application) {
$commands = ['city' => 'CityController', 'currency' => 'CurrencyController', 'dumper' => 'DumperController', 'carono' => 'CaronoController'];
foreach ($commands as $name => $command) {
$name = file_exists(\Yii::getAlias("@app/commands/{$command}.php")) ? "carono" . ucfirst($name) : $name;
$app->controllerMap[$name] = 'carono\\components\\commands\\' . $command;
}
if (!isset($app->controllerMap['giix'])) {
if (($gii = $app->getModule('gii')) && isset($gii->generators["giiant-model"])) {
if (!isset($gii->generators["giiant-model"]["templates"])) {
if (is_array($gii->generators["giiant-model"])) {
$gii->generators["giiant-model"]["templates"] = [];
} else {
$gii->generators["giiant-model"] = ["class" => 'schmunk42\\giiant\\generators\\model\\Generator', "templates" => []];
}
}
$template = '@vendor/carono/yii2-components/templates/giiant-model';
$gii->generators["giiant-model"]["templates"]["caronoModel"] = $template;
$app->controllerMap['giix'] = 'carono\\components\\commands\\GiixController';
}
}
}
}
示例8: 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);
}
}
示例9: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
*
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
if ($app->hasModule('gii')) {
if (!isset($app->getModule('gii')->generators['migen'])) {
$app->getModule('gii')->generators['migen'] = 'sirroland\\migen\\gii\\Generator';
}
}
}
示例10: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
if ($app->hasModule('gii')) {
if (!isset($app->getModule('gii')->generators['fixture-generator'])) {
$app->getModule('gii')->generators['fixture-generator'] = ['class' => __NAMESPACE__ . '\\FixtureGenerator'];
}
}
}
示例11: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
*
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
if ($app->hasModule('gii')) {
if ($app instanceof \yii\console\Application) {
$app->controllerMap['gii-batch'] = 'cornernote\\gii\\commands\\BatchController';
}
}
}
示例12: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
if ((isset($_GET['_xhprof']) || isset($_COOKIE['_xhprof'])) && function_exists('xhprof_enable')) {
$app->on(Application::EVENT_BEFORE_REQUEST, function () use($app) {
\xhprof_enable(\XHPROF_FLAGS_CPU + \XHPROF_FLAGS_MEMORY);
});
}
}
示例13: addUrlRules
/**
* Add default url rules of this module to custom urlManager of application
* @param \yii\base\Application $app
*/
public function addUrlRules(\yii\base\Application $app)
{
if ($app instanceof \yii\web\Application) {
$app->getUrlManager()->addRules([['prefix' => $this->urlRulePrefix, 'class' => $this->urlRuleClass, 'controller' => [$this->id . '/user'], 'extraPatterns' => ['POST current' => 'current', 'POST extend' => 'extend'], 'pluralize' => false]]);
} elseif ($app instanceof \yii\console\Application) {
$app->controllerMap[$this->id] = ['class' => 'gbksoft\\modules\\tokens\\console\\AppController', 'module' => $this];
}
}
示例14: 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()];
}
}
示例15: bootstrap
/**
* Bootstrap method to be called during application bootstrap stage.
*
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
if ($app->hasModule('gii')) {
if (!isset($app->getModule('gii')->generators['singletonn-gii'])) {
$app->getModule('gii')->generators['singletonn-gii-model'] = 'singletonn\\gii\\model\\Generator';
$app->getModule('gii')->generators['singletonn-gii-crud'] = 'singletonn\\gii\\crud\\Generator';
}
}
}