[CORE][DB][ENTITY][Actor] Add `DB::removeBy` and use it in `Actor->setSelfTags`

This commit is contained in:
Hugo Sales 2021-11-28 12:13:30 +00:00 committed by Diogo Peralta Cordeiro
parent 66ff3c594d
commit fc81f7301c
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
2 changed files with 12 additions and 8 deletions

View File

@ -224,6 +224,11 @@ class DB
} }
} }
public static function removeBy(string $table, array $criteria)
{
self::remove(self::getReference($table, $criteria));
}
public static function count(string $table, array $criteria) public static function count(string $table, array $criteria)
{ {
/** @var EntityRepository */ /** @var EntityRepository */

View File

@ -365,8 +365,7 @@ class Actor extends Entity
$actor_tag = DB::findOneBy('actor_tag', ['tagger' => $this->getId(), 'tagged' => $this->getId(), 'tag' => $actor_circle->getTag()]); $actor_tag = DB::findOneBy('actor_tag', ['tagger' => $this->getId(), 'tagged' => $this->getId(), 'tag' => $actor_circle->getTag()]);
DB::persist($actor_tag); DB::persist($actor_tag);
DB::remove($actor_tag); DB::remove($actor_tag);
// TODO: use DB::removeBy when implemented DB::removeBy('actor_circle', ['id' => $actor_circle->getId()]);
DB::remove(DB::getReference('actor_circle', ['id' => $actor_circle->getId()]));
} }
Cache::delete("selftags-{$this->getId()}"); Cache::delete("selftags-{$this->getId()}");
Cache::delete("othertags-{$this->getId()}-by-{$this->getId()}"); Cache::delete("othertags-{$this->getId()}-by-{$this->getId()}");