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


PHP Application::set方法代码示例

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


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

示例1: 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

示例2: registerComponents

 /**
  * 
  * @param Application $app
  */
 public function registerComponents($app)
 {
     $count = 0;
     foreach ($this->coreComponents() as $id => $component) {
         try {
             $app->set($id, $component);
         } catch (\Exception $ex) {
             Yii::error("`{$id}` failed to register: " . $ex->getMessage(), __METHOD__);
             continue;
         }
         Yii::info("`{$id}` registered.", __METHOD__);
         $count++;
     }
     return $count;
 }
开发者ID:rhoone,项目名称:yii2-rhoone,代码行数:19,代码来源:Module.php

示例3: bootstrap

 /**
  * - route translations
  * @param \yii\base\Application $app
  */
 public function bootstrap($app)
 {
     //        \Yii::info(__CLASS__);
     //        $app->attachBehavior('AppConfigBehavior', 'cza\base\behaviors\AppConfigBehavior');
     //
     //        $app->i18n->translations['cza*'] = [
     //            'class' => 'yii\i18n\PhpMessageSource',
     //            'sourceLanguage' => 'en-US',
     //            'basePath' => '@cza/base/messages',
     //            'fileMap' => [
     //                'cza' => 'default.php',
     //                'cza/languages' => 'languages.php',
     //            ],
     //        ];
     //
     // declare CZA Helper
     $app->set('czaHelper', ['class' => '\\cza\\base\\helpers\\Helper']);
 }
开发者ID:bennybi,项目名称:yii2-cza-base,代码行数:22,代码来源:Bootstrap.php

示例4: bootstrap

 /**
  * Bootstrap method to be called during application bootstrap stage.
  * @param Application $app the application currently running
  */
 public function bootstrap($app)
 {
     $app->on(Application::EVENT_BEFORE_REQUEST, function () use($app) {
         try {
             /*******************************
                /* Mailer
                /*******************************/
             // Set default transport class
             $transport = ['class' => 'Swift_MailTransport'];
             // Change transport class to SMTP if was selected
             if (isset($app->params['App.Mailer.transport']) && $app->params['App.Mailer.transport'] === 'smtp') {
                 $transport = ['class' => 'Swift_SmtpTransport', 'host' => $app->settings->get("smtp.host"), 'username' => $app->settings->get("smtp.username"), 'password' => base64_decode($app->settings->get("smtp.password")), 'port' => $app->settings->get("smtp.port"), 'encryption' => $app->settings->get("smtp.encryption") == 'none' ? null : $app->settings->get("smtp.encryption")];
             }
             // Set mail queue component as mailer
             $app->set('mailer', ['class' => 'app\\components\\queue\\MailQueue', 'mailsPerRound' => 10, 'maxAttempts' => 3, 'transport' => $transport, 'messageConfig' => ['charset' => 'UTF-8']]);
             /*******************************
                /* User session
                /*******************************/
             if (isset($app->user) && !$app->user->isGuest) {
                 /** @var \app\models\Profile $profile */
                 $profile = $app->user->identity->profile;
                 // Setting the timezone to the current users timezone
                 if (isset($profile->timezone)) {
                     $app->setTimeZone($profile->timezone);
                 }
                 // Setting the language to the current users language
                 if (isset($profile->language)) {
                     $app->language = $profile->language;
                 }
             }
         } catch (\Exception $e) {
             // Do nothing
         }
     });
     /*******************************
        /* Event Handlers
        /*******************************/
     $app->on('app.form.submission.received', ['app\\events\\handlers\\SubmissionEventHandler', 'onSubmissionReceived']);
     $app->on('app.form.submission.accepted', ['app\\events\\handlers\\SubmissionEventHandler', 'onSubmissionAccepted']);
     $app->on('app.form.submission.rejected', ['app\\events\\handlers\\SubmissionEventHandler', 'onSubmissionRejected']);
 }
开发者ID:ramialcheikh,项目名称:quickforms,代码行数:45,代码来源:Bootstrap.php

示例5: bootstrap

 /**
  * Bootstrap method to be called during application bootstrap stage.
  *
  * @param Application $app the application currently running
  */
 public function bootstrap($app)
 {
     $app->set('metaData', ['class' => 'steeple\\meta\\MetaData']);
 }
开发者ID:steeple,项目名称:yii2-meta,代码行数:9,代码来源:Bootstrap.php


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