コード例 #1
0
 /**
  * @inheritdoc
  */
 public function afterDelete()
 {
     Tagging::deleteAll(['taggable_type' => Tagging::TAGGABLE_VIDEO, 'taggable_id' => $this->id]);
     Relation::deleteAll(['relationable_type' => Relation::RELATIONABLE_VIDEO, 'relationable_id' => $this->id]);
     Comment::deleteAll(['commentable_type' => Comment::COMMENTABLE_VIDEO, 'commentable_id' => $this->id]);
     CommentCount::deleteAll(['commentable_type' => CommentCount::COMMENTABLE_VIDEO, 'commentable_id' => $this->id]);
     $assets = Asset::find()->where(['assetable_type' => Asset::ASSETABLE_VIDEO, 'assetable_id' => $this->id])->orWhere(['assetable_type' => Asset::ASSETABLE_VIDEOFILE, 'assetable_id' => $this->id])->all();
     foreach ($assets as $asset) {
         $asset->delete();
     }
 }
コード例 #2
0
 /**
  * Deletes an existing Tag model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $tag = $this->findModel($id);
     $taggings = Tagging::find()->where(['taggable_type' => Tagging::TAGGABLE_POST, 'tag_id' => $id])->all();
     foreach ($taggings as $tagging) {
         $post = Post::findOne($tagging->taggable_id);
         if ($post) {
             $cached_tag_list = [];
             $newTags = $post->getTags();
             foreach ($newTags as $newTag) {
                 if (strcmp($tag->name, $newTag->name) !== 0) {
                     $cached_tag_list[] = $newTag->name;
                 }
             }
             $post->cached_tag_list = implode(', ', $cached_tag_list);
             $post->save(true, ['cached_tag_list']);
         }
     }
     Tagging::deleteAll(['tag_id' => $tag->id]);
     $tag->delete();
     return $this->redirect(['index']);
 }
コード例 #3
0
ファイル: Post.php プロジェクト: alexsynytskiy/Dynamomania
 /**
  * @inheritdoc
  */
 public function afterDelete()
 {
     $this->updateCacheBlocks();
     Tagging::deleteAll(['taggable_type' => Tagging::TAGGABLE_POST, 'taggable_id' => $this->id]);
     Relation::deleteAll(['relationable_type' => Relation::RELATIONABLE_POST, 'relationable_id' => $this->id]);
     Comment::deleteAll(['commentable_type' => Comment::COMMENTABLE_POST, 'commentable_id' => $this->id]);
     CommentCount::deleteAll(['commentable_type' => CommentCount::COMMENTABLE_POST, 'commentable_id' => $this->id]);
     SelectedBlog::deleteAll(['post_id' => $this->id]);
     $assets = Asset::find()->where(['assetable_type' => Asset::ASSETABLE_POST, 'assetable_id' => $this->id])->all();
     foreach ($assets as $asset) {
         $asset->delete();
     }
 }