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


PHP base\Module类代码示例

本文整理汇总了PHP中yii\base\Module的典型用法代码示例。如果您正苦于以下问题:PHP Module类的具体用法?PHP Module怎么用?PHP Module使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: init

 public function init()
 {
     parent::init();
     if (is_null($this->attribute)) {
         throw new Exception("Module \"attribute\" attribute must be set");
     }
     if (is_null($this->latitudeAttribute)) {
         throw new Exception("Module \"latitudeAttribute\" attribute must be set");
     }
     if (is_null($this->longitudeAttribute)) {
         throw new Exception("Module \"longitudeAttribute\" attribute must be set");
     }
     if (is_null($this->jsonAttribute)) {
         throw new Exception("Module \"jsonAttribute\" attribute must be set");
     }
     if (is_null($this->class)) {
         $this->class = __NAMESPACE__ . '\\models\\Locations';
     }
     $location = new $this->class();
     $location->setAttributes(['destinationAttribute' => $this->attribute, 'latitudeAttribute' => $this->latitudeAttribute, 'longitudeAttribute' => $this->longitudeAttribute, 'jsonAttribute' => $this->jsonAttribute]);
     $this->location = $location;
     Event::on(Locations::className(), Locations::EVENT_ADD_LOCATION, [Locations::className(), 'addLocation']);
     Event::on(Locations::className(), Locations::EVENT_GET_LOCATION, [Locations::className(), 'getLocation']);
     return true;
 }
开发者ID:achertovsky,项目名称:maplocation,代码行数:25,代码来源:Module.php

示例2: getModulePermissions

 /**
  * @inheritdoc
  */
 protected function getModulePermissions(\yii\base\Module $module)
 {
     if ($module instanceof \humhub\components\Module) {
         return $module->getPermissions($this->contentContainer);
     }
     return [];
 }
开发者ID:SimonBaeumer,项目名称:humhub,代码行数:10,代码来源:ContentContainerPermissionManager.php

示例3: init

 public function init()
 {
     parent::init();
     if (!\Yii::$app->user->can('adminDashboard')) {
         throw new ForbiddenHttpException('Access denied');
     }
 }
开发者ID:mops1k,项目名称:yiimine,代码行数:7,代码来源:Module.php

示例4: init

 public function init()
 {
     parent::init();
     if (!isset(Yii::$app->i18n->translations['forum'])) {
         Yii::$app->i18n->translations['forum'] = ['class' => 'yii\\i18n\\PhpMessageSource', 'sourceLanguage' => 'en', 'basePath' => '@backend/modules/forum/messages'];
     }
 }
开发者ID:rocketyang,项目名称:iisns,代码行数:7,代码来源:ForumModule.php

示例5: init

 public function init()
 {
     parent::init();
     /*if ($app instanceof \yii\console\Application) {
     			$$this->controllerNamespace;
     		}*/
 }
开发者ID:mmelcor,项目名称:yii2-transconv,代码行数:7,代码来源:Module.php

示例6: run

 /**
  * Run the job.
  * 
  * @param Job $job
  */
 public function run(Job $job)
 {
     \Yii::info('Running job', 'yii2queue');
     try {
         if ($job->isCallable()) {
             $retval = $job->runCallable();
         } else {
             $retval = $this->module->runAction($job->route, $job->data);
         }
     } catch (\Exception $e) {
         if ($job->isCallable()) {
             if (isset($job->header['signature']) && isset($job->header['signature']['route'])) {
                 $id = $job->id . " " . \yii\helpers\Json::encode($job->header['signature']['route']);
             } else {
                 $id = $job->id . ' callable';
             }
         } else {
             $id = $job->route;
         }
         \Yii::error("Fatal Error: Error running route '{$id}'. Message: {$e->getMessage()}", 'yii2queue');
         throw new \yii\base\Exception("Error running route '{$id}'. Message: {$e->getMessage()}. File: {$e->getFile()}[{$e->getLine()}]. Stack Trace: {$e->getTraceAsString()}", 500);
     }
     if ($retval !== false) {
         \Yii::info('Deleting job', 'yii2queue');
         $this->delete($job);
     }
 }
开发者ID:tajhulfaijin,项目名称:yii2-queue,代码行数:32,代码来源:Queue.php

示例7: init

 /**
  * @inheritdoc
  * @throws InvalidConfigException
  */
 public function init()
 {
     if (\Yii::$app->authManager === null) {
         throw new InvalidConfigException('You forgot configure the "authManager" component.');
     }
     parent::init();
 }
开发者ID:vandro,项目名称:gui-rbac-yii2,代码行数:11,代码来源:Module.php

示例8: beforeAction

 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         // Запретим доступ неавторизованным пользователям
         //            TODO убрать запрет и сделать нормальные поведения
         if (Yii::$app->getUser()->isGuest) {
             throw new ForbiddenHttpException('У вас нет прав просматривать данную страницу.');
         }
         if (isset($action->controller->breadcrumbItems)) {
             $action->controller->addBreadcrumbsItem(['label' => 'Личный кабинет', 'url' => ['/cabinet']]);
             $items = $action->controller->breadcrumbItems[$action->id];
             if ($items === 'not add') {
                 // Просто выходим и разрешаем выолнять Action
                 return true;
             }
             if (is_array($items)) {
                 foreach ($items as $item) {
                     if (isset($item['url'])) {
                         $action->controller->addBreadcrumbsItem(['label' => $item['label'], 'url' => $item['url']]);
                     } else {
                         $action->controller->addBreadcrumbsItem(['label' => $item['label']]);
                     }
                 }
             } else {
                 $action->controller->addBreadcrumbsItem(['label' => $items]);
             }
         } else {
             $action->controller->addBreadcrumbsItem(['label' => 'Личный кабинет']);
         }
         return true;
         // or false if needed
     } else {
         return false;
     }
 }
开发者ID:Sywooch,项目名称:TailorPlace,代码行数:35,代码来源:Cabinet.php

示例9: init

 public function init()
 {
     parent::init();
     if (\Yii::$app instanceof \yii\console\Application) {
         $this->controllerNamespace = 'common\\modules\\rbac\\commands';
     }
 }
开发者ID:Humanized,项目名称:viajero,代码行数:7,代码来源:Module.php

示例10: init

 public function init()
 {
     // Menu backend
     $this->backendMenu = [['label' => Yii::t('message', 'Message'), 'url' => ['/message/default'], 'access' => ['message/backend/default/*', 'message/backend/default/index']], ['label' => Yii::t('common', 'Setting'), 'url' => ['/common/setting', 'module' => 'message'], 'access' => ['common/setting']]];
     parent::init();
     // custom initialization code goes here
 }
开发者ID:quynhvv,项目名称:stepup,代码行数:7,代码来源:Module.php

示例11: init

 public function init()
 {
     parent::init();
     //        \Yii::$app->request->setAcceptableContentTypes(['application/json' => ['q' => 1]]);
     \Yii::$app->user->enableSession = false;
     Helper::handle_response();
 }
开发者ID:nisnaker,项目名称:yii2-template,代码行数:7,代码来源:Module.php

示例12: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $handler = new \yii\web\ErrorHandler(['errorAction' => 'empresas/default/error', 'errorView' => '@app/modules/empresas/views/default/error.php']);
     Yii::$app->set('errorHandler', $handler);
     $handler->register();
 }
开发者ID:alejandrososa,项目名称:AB,代码行数:10,代码来源:Modulo.php

示例13: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->userIdentityClass === null) {
         $this->userIdentityClass = \Yii::$app->getUser()->identityClass;
     }
 }
开发者ID:frenzelgmbh,项目名称:cm-communication,代码行数:10,代码来源:Module.php

示例14: init

 /**
  * 
  */
 public function init()
 {
     $modulePathAlias = '@app/modules/' . $this->id;
     parent::init();
     $this->controllerNamespace = 'app\\modules\\' . $this->id . '\\controllers';
     Yii::$app->getI18n()->translations[$this->id . '*'] = ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => $modulePathAlias . '/messages'];
 }
开发者ID:sheillendra,项目名称:yii2-jeasyui,代码行数:10,代码来源:Module.php

示例15: init

 public function init()
 {
     if (Yii::$app->user->isGuest || Yii::$app->user->id > 5) {
         die("Доступ закрыт! Вы не являетесь админом.");
     }
     parent::init();
 }
开发者ID:Nechhist,项目名称:to.ru,代码行数:7,代码来源:AdminModule.php


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