/**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     // set upload config
     $this->uploadConfig = [$this->crudModelsClass['main'] => []];
     $this->on(self::EVENT_DELETE, function ($event) {
         foreach ($event->extraData['models'] as $model) {
             CmsMenuSimpleService::refreshMenu($model->cms_simple_menu_group_id);
         }
     });
     $this->on(self::EVENT_SAVE_EDIT, function ($event) {
         CmsMenuSimpleService::refreshMenu($event->extraData['models']['main']->cms_simple_menu_group_id);
     });
     $this->on(self::EVENT_SAVE_TRANSLATE, function ($event) {
         $listId = [];
         foreach ($event->extraData['models'] as $model) {
             if (!in_array($model->cms_simple_menu_id, $listId)) {
                 $listId[] = $model->cms_simple_menu_id;
             }
         }
         $cmsSimpleMenus = CmsSimpleMenu::find()->select('cms_simple_menu_group_id')->where(['id' => $listId])->asArray()->all();
         foreach ($cmsSimpleMenus as $cmsSimpleMenu) {
             CmsMenuSimpleService::refreshMenu($cmsSimpleMenu['cms_simple_menu_group_id']);
         }
     });
 }
Exemple #2
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     $attributeLabels = parent::attributeLabels();
     $attributeLabels['cms_simple_menu_i18n_title'] = Yii::t('kalibao', 'model:title');
     $attributeLabels['cms_simple_menu_i18n_url'] = Yii::t('kalibao', 'cms_simple_menu:url');
     $attributeLabels['cms_simple_menu_group_i18n_title'] = Yii::t('kalibao', 'cms_simple_menu:cms_simple_menu_group_id');
     return $attributeLabels;
 }
Exemple #3
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     if ($this->menuGroupId === null) {
         throw new \yii\base\InvalidParamException();
     }
     $this->models = CmsSimpleMenu::getDb()->cache(function ($db) {
         return CmsSimpleMenu::find()->innerJoinWith(['cmsSimpleMenuI18ns' => function ($query) {
             $query->where(['i18n_id' => Yii::$app->language]);
         }])->where(['cms_simple_menu_group_id' => $this->menuGroupId])->orderBy('position')->asArray()->all();
     }, 0, new TagDependency(['tags' => [CmsMenuSimpleService::getCacheTag(), CmsMenuSimpleService::getCacheTag($this->menuGroupId)]]));
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCmsSimpleMenus()
 {
     return $this->hasMany(CmsSimpleMenu::className(), ['cms_simple_menu_group_id' => 'id']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCmsSimpleMenu()
 {
     return $this->hasOne(CmsSimpleMenu::className(), ['id' => 'cms_simple_menu_id']);
 }