Improved public API in Tag entity, avoiding anemic model

This commit is contained in:
Alejandro Celaya
2018-10-28 14:38:43 +01:00
parent f7ceeff05a
commit 084b1169d7
11 changed files with 23 additions and 25 deletions

View File

@@ -22,7 +22,7 @@ trait TagManagerTrait
$entities = [];
foreach ($tags as $tagName) {
$tagName = $this->normalizeTagName($tagName);
$tag = $em->getRepository(Tag::class)->findOneBy(['name' => $tagName]) ?: (new Tag())->setName($tagName);
$tag = $em->getRepository(Tag::class)->findOneBy(['name' => $tagName]) ?: new Tag($tagName);
$em->persist($tag);
$entities[] = $tag;
}