mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-11 01:33:11 +08:00
Removed non-used deprecated method and added missing tests
This commit is contained in:
@@ -128,16 +128,6 @@ class ShortUrl extends AbstractEntity
|
||||
return $this->tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection|Tag[] $tags
|
||||
* @deprecated Use ShortUrl::update to set the tags on this ShortUrl
|
||||
*/
|
||||
public function setTags(Collection $tags): self
|
||||
{
|
||||
$this->tags = $tags;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function update(
|
||||
ShortUrlEdit $shortUrlEdit,
|
||||
?ShortUrlRelationResolverInterface $relationResolver = null
|
||||
|
||||
@@ -38,8 +38,13 @@ class PersistenceShortUrlRelationResolver implements ShortUrlRelationResolverInt
|
||||
*/
|
||||
public function resolveTags(array $tags): Collections\Collection
|
||||
{
|
||||
return new Collections\ArrayCollection(map($tags, function (string $tagName): Tag {
|
||||
$tag = $this->em->getRepository(Tag::class)->findOneBy(['name' => $tagName]) ?? new Tag($tagName);
|
||||
if (empty($tags)) {
|
||||
return new Collections\ArrayCollection();
|
||||
}
|
||||
|
||||
$repo = $this->em->getRepository(Tag::class);
|
||||
return new Collections\ArrayCollection(map($tags, function (string $tagName) use ($repo): Tag {
|
||||
$tag = $repo->findOneBy(['name' => $tagName]) ?? new Tag($tagName);
|
||||
$this->em->persist($tag);
|
||||
|
||||
return $tag;
|
||||
|
||||
Reference in New Issue
Block a user