示例#1
0
 /**
  * Создает компонент
  * @param \app\modules\banners\models\Banner $model модель баннера
  * @return null|AbstractRenderer
  * @throws \yii\base\InvalidConfigException
  */
 public function createRenderer(\app\modules\banners\models\Banner $model)
 {
     $file = $model->getFirstFile('image');
     if (!$file) {
         return null;
     }
     if ($file->isImage()) {
         return Yii::createObject(ImageRenderer::className(), [$model]);
     } else {
         return Yii::createObject(FlashRenderer::className(), [$model]);
     }
 }
示例#2
0
 /**
  * Действия
  * @return array
  */
 public function actions()
 {
     $class = Banner::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]];
 }
示例#3
0
<?php

use app\modules\banners\models;
return ['controllerMap' => ['migrate' => ['migrationLookup' => ['@webapp/modules/banners/migrations']]], 'modules' => ['banners' => ['class' => 'app\\modules\\banners\\Banners', 'controllerNamespace' => 'app\\modules\\banners\\controllers', 'components' => ['rendererFactory' => \app\modules\banners\components\RendererFactory::className()], 'modules' => ['admin' => ['class' => 'app\\modules\\banners\\modules\\admin\\Admin', 'controllerNamespace' => 'app\\modules\\banners\\modules\\admin\\controllers', 'menuItems' => function () {
    return [['label' => Yii::t('banners/app', 'Banners module'), 'icon' => 'glyphicon glyphicon-picture', 'items' => [['label' => Yii::t('banners/app', 'Banners'), 'url' => ['/admin/banners/banner'], "permission" => ["listModels", ["model" => Yii::createObject(models\Banner::className())]]], ['label' => Yii::t('banners/app', 'Places'), 'url' => ['/admin/banners/place'], "permission" => ["listModels", ["model" => Yii::createObject(models\Place::className())]]]]]];
}]]]], 'components' => ['i18n' => ['translations' => ['banners/*' => ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => '@webapp/modules/banners/messages', 'fileMap' => ['banners/app' => 'app.php']]]], 'urlManager' => ['rules' => []]]];
示例#4
0
 /**
  * Связь с баннерами
  * @return \yii\db\ActiveQuery
  */
 public function getBanners()
 {
     return $this->hasMany(Banner::className(), ["place_id" => "id"]);
 }