Ensured domain is taken into account when checking if a slug is in use

This commit is contained in:
Alejandro Celaya
2019-10-01 21:42:35 +02:00
parent 8da6b336f5
commit 495643f4f1
9 changed files with 130 additions and 36 deletions

View File

@@ -7,8 +7,13 @@ use function sprintf;
class NonUniqueSlugException extends InvalidArgumentException
{
public static function fromSlug(string $slug): self
public static function fromSlug(string $slug, ?string $domain): self
{
return new self(sprintf('Provided slug "%s" is not unique.', $slug));
$suffix = '';
if ($domain !== null) {
$suffix = sprintf(' for domain "%s"', $domain);
}
return new self(sprintf('Provided slug "%s" is not unique%s.', $slug, $suffix));
}
}