當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。