Created command that allows configuring not found redirects for every domain

This commit is contained in:
Alejandro Celaya
2021-07-21 21:09:33 +02:00
parent 4642480bbb
commit 021cecc216
13 changed files with 269 additions and 24 deletions

View File

@@ -5,28 +5,48 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Core\Domain\Model;
use JsonSerializable;
use Shlinkio\Shlink\Core\Config\NotFoundRedirectConfigInterface;
use Shlinkio\Shlink\Core\Entity\Domain;
final class DomainItem implements JsonSerializable
{
public function __construct(private string $domain, private bool $isDefault)
private function __construct(
private string $authority,
private NotFoundRedirectConfigInterface $notFoundRedirectConfig,
private bool $isDefault
) {
}
public static function forExistingDomain(Domain $domain): self
{
return new self($domain->getAuthority(), $domain, false);
}
public static function forDefaultDomain(string $authority, NotFoundRedirectConfigInterface $config): self
{
return new self($authority, $config, true);
}
public function jsonSerialize(): array
{
return [
'domain' => $this->domain,
'domain' => $this->authority,
'isDefault' => $this->isDefault,
];
}
public function toString(): string
{
return $this->domain;
return $this->authority;
}
public function isDefault(): bool
{
return $this->isDefault;
}
public function notFoundRedirectConfig(): NotFoundRedirectConfigInterface
{
return $this->notFoundRedirectConfig;
}
}