Updated short URL edition so that it supports editing tags

This commit is contained in:
Alejandro Celaya
2021-01-31 12:12:21 +01:00
parent c58fa586e1
commit 977058d219
5 changed files with 41 additions and 5 deletions

View File

@@ -138,8 +138,10 @@ class ShortUrl extends AbstractEntity
return $this;
}
public function update(ShortUrlEdit $shortUrlEdit): void
{
public function update(
ShortUrlEdit $shortUrlEdit,
?ShortUrlRelationResolverInterface $relationResolver = null
): void {
if ($shortUrlEdit->hasValidSince()) {
$this->validSince = $shortUrlEdit->validSince();
}
@@ -152,6 +154,10 @@ class ShortUrl extends AbstractEntity
if ($shortUrlEdit->hasLongUrl()) {
$this->longUrl = $shortUrlEdit->longUrl();
}
if ($shortUrlEdit->hasTags()) {
$relationResolver = $relationResolver ?? new SimpleShortUrlRelationResolver();
$this->tags = $relationResolver->resolveTags($shortUrlEdit->tags());
}
}
/**