public function init() { if (!$this->isShow()) { return false; } if ($this->model === null) { $this->model = Model::findByCode($this->code); } }
/** * Действия * @return array */ public function actions() { $class = Includes::className(); return ['index' => ['class' => crud\Admin::className(), 'modelClass' => $class], 'create' => ['class' => crud\Create::className(), 'modelClass' => $class], 'update' => ['class' => crud\Update::className(), 'modelClass' => $class], 'view' => ['class' => crud\View::className(), 'modelClass' => $class], 'delete' => ['class' => crud\Delete::className(), 'modelClass' => $class], 'groupdelete' => ['class' => crud\GroupDelete::className(), 'modelClass' => $class], 'editable' => ['class' => crud\XEditable::className(), 'modelClass' => $class]]; }
/** * Список включаемых областей * @return array */ public function getIncludesList() { $models = Includes::find()->orderBy(["title" => SORT_ASC])->all(); return ArrayHelper::map($models, "id", "title"); }
<?php use app\modules\main\models; return ['controllerMap' => ['migrate' => ['migrationLookup' => ['@webapp/modules/main/migrations']]], 'modules' => ['main' => ['class' => app\modules\main\Main::className(), 'controllerNamespace' => 'app\\modules\\main\\controllers', 'components' => ['tagsConverter' => \common\components\TagsConverter::className(), 'sphinxUrlService' => \app\modules\main\components\SphinxUrlService::className(), 'sitemap' => ["class" => \app\modules\main\sitemap\Sitemap::className(), "definition" => [['class' => 'app\\modules\\main\\models\\Pages', 'urlCreate' => function ($model) { return Yii::$app->urlManager->createUrl(['/main/pages/index', 'model' => $model]); }]]], 'config' => ['class' => \app\modules\main\components\Config::className()], 'treeFinder' => ['class' => \common\components\TreeFinder::className()], 'blocksProvider' => ['class' => \app\modules\main\components\BlocksProvider::className()]], 'modules' => ['admin' => ['class' => app\modules\main\modules\admin\Admin::className(), 'controllerNamespace' => 'app\\modules\\main\\modules\\admin\\controllers', 'menuItems' => function () { return [['label' => Yii::t('main/app', 'Main module'), 'icon' => 'glyphicon glyphicon-home', 'items' => [['label' => Yii::t('main/app', 'Pages'), 'url' => ['/admin/main/pages'], "permission" => ["listModels", ["model" => Yii::createObject(models\Pages::className())]]], ['label' => Yii::t('main/app', 'Menu'), 'url' => ['/admin/main/menu'], "permission" => ["listModels", ["model" => Yii::createObject(models\Menu::className())]]], ['label' => Yii::t('main/app', 'Users'), 'url' => ['/admin/main/user'], "permission" => ["listModels", ["model" => Yii::createObject(models\User::className())]]], ['label' => Yii::t('main/app', 'FileManager'), 'url' => ['/admin/main/file-manager'], "permission" => ["fileManager"]], ['label' => Yii::t('main/app', 'Templates'), 'url' => ['/admin/main/template'], "permission" => ["rootAccess"]], ['label' => Yii::t('main/app', 'Includes'), 'url' => ['/admin/main/includes'], "permission" => ["listModels", ["model" => Yii::createObject(models\Includes::className())]]], ['label' => Yii::t('main/app', 'Include Groups'), 'url' => ['/admin/main/include-group'], "permission" => ["listModels", ["model" => Yii::createObject(models\IncludeGroup::className())]]], ['label' => Yii::t('main/app', 'Comments'), 'url' => ['/admin/main/comments'], "permission" => ["listModels", ["model" => Yii::createObject(models\Comments::className())]]], ['label' => Yii::t('main/app', 'Reviews'), 'url' => ['/admin/main/review'], "permission" => ["listModels", ["model" => Yii::createObject(models\Review::className())]]], ['label' => Yii::t('main/app', 'Tools'), 'url' => ['/admin/main/tools'], "permission" => ["rootAccess"]], ['label' => Yii::t('main/app', 'Permission'), 'url' => ['/admin/main/permission'], "permission" => ["rootAccess"]], ['label' => Yii::t('main/app', 'Config'), 'url' => ['/admin/main/config'], "permission" => ["rootAccess"]]]]]; }]]]], 'components' => ['i18n' => ['translations' => ['main/*' => ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => '@webapp/modules/main/messages', 'fileMap' => ['main/app' => 'app.php']]]], 'urlManager' => ['rules' => ['user/<action:[A-z0-9_-]+>' => 'main/user/<action>', 'user' => 'main/user/profile', ['class' => '\\app\\modules\\main\\components\\PageUrlRule']]]]];
/** * Связь с включаемымы областями * @return ActiveQueryInterface */ public function getIncludes() { return $this->hasMany(Includes::className(), ['id' => 'include_id'])->viaTable('groups_to_includes', ['group_id' => 'id']); }