Exemplo n.º 1
0
 /**
  * Удаляем связанные SliderImage (а они удалят в свою очередь картинки)
  *
  * @return bool
  */
 public function beforeDelete()
 {
     if (parent::beforeDelete()) {
         foreach ($this->sliderImages as $sliderImage) {
             $sliderImage->delete();
         }
         return true;
     }
     return false;
 }
 /**
  * Invalidate cache
  */
 public function afterDelete()
 {
     TagDependency::invalidate(Yii::$app->cache, ContentModule::CACHE_TAG);
     parent::afterDelete();
 }
Exemplo n.º 3
0
 /**
  * @param bool  $insert
  * @param array $changedAttributes
  */
 public function afterSave($insert, $changedAttributes)
 {
     Yii::$app->cache->flush();
     parent::afterSave($insert, $changedAttributes);
 }
Exemplo n.º 4
0
 /**
  * Generate url from the name
  *
  * @return bool
  */
 public function beforeValidate()
 {
     $this->url = $this->url ? $this->url : LittleBigHelper::slug($this->name);
     return parent::beforeValidate();
 }
Exemplo n.º 5
0
 public function afterDelete()
 {
     $this->deleteImage($this->image);
     parent::afterDelete();
 }
Exemplo n.º 6
0
 /**
  * Invalidate cache
  */
 public function afterDelete()
 {
     $this->deleteImage($this->menu_image);
     TagDependency::invalidate(Yii::$app->cache, ContentModule::CACHE_TAG);
     parent::afterDelete();
 }
Exemplo n.º 7
0
 /**
  * Invalidate cache
  *
  * @inheritdoc
  */
 public function afterDelete()
 {
     parent::afterDelete();
     Yii::$app->cache->delete('__globalMetaTags');
 }
Exemplo n.º 8
0
 /**
  * Create ContentTemplateWidget or update it
  *
  * @inheritdoc
  */
 public function afterSave($insert, $changedAttributes)
 {
     if ($insert) {
         $widget = new ContentTemplateWidget();
         $widget->name = $this->name;
         $widget->position = $this->position;
         $widget->widget_class = self::WIDGET_CLASS;
         $widget->code = md5(__CLASS__ . '_' . $this->id);
         $widget->widget_options = serialize(['code' => $this->code]);
         $widget->has_settings = 1;
         $widget->link_to_settings = '/content/content-page/tree?menuId=' . $this->id;
         $widget->save(false);
     } elseif (array_key_exists('name', $changedAttributes) || array_key_exists('position', $changedAttributes) || array_key_exists('code', $changedAttributes)) {
         $widget = ContentTemplateWidget::findOne(['widget_class' => self::WIDGET_CLASS, 'code' => md5(__CLASS__ . '_' . $this->id)]);
         if ($widget) {
             $widget->name = $this->name;
             $widget->position = $this->position;
             $widget->widget_options = serialize(['code' => $this->code]);
             $widget->save(false);
         }
     }
     TagDependency::invalidate(Yii::$app->cache, ContentModule::CACHE_TAG);
     parent::afterSave($insert, $changedAttributes);
 }