Added redirects to the list of domains

This commit is contained in:
Alejandro Celaya
2021-08-03 17:00:26 +02:00
parent 7b43403b1c
commit 565fe4c348
6 changed files with 60 additions and 8 deletions

View File

@@ -28,6 +28,11 @@ final class NotFoundRedirects implements JsonSerializable
return new self(null, null, null);
}
public static function fromConfig(NotFoundRedirectConfigInterface $config): self
{
return new self($config->baseUrlRedirect(), $config->regular404Redirect(), $config->invalidShortUrlRedirect());
}
public function baseUrlRedirect(): ?string
{
return $this->baseUrlRedirect;

View File

@@ -6,6 +6,7 @@ namespace Shlinkio\Shlink\Core\Domain\Model;
use JsonSerializable;
use Shlinkio\Shlink\Core\Config\NotFoundRedirectConfigInterface;
use Shlinkio\Shlink\Core\Config\NotFoundRedirects;
use Shlinkio\Shlink\Core\Entity\Domain;
final class DomainItem implements JsonSerializable
@@ -32,6 +33,7 @@ final class DomainItem implements JsonSerializable
return [
'domain' => $this->authority,
'isDefault' => $this->isDefault,
'redirects' => NotFoundRedirects::fromConfig($this->notFoundRedirectConfig),
];
}

View File

@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Core\Domain\Repository;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use Happyr\DoctrineSpecification\Repository\EntitySpecificationRepository;
use Happyr\DoctrineSpecification\Spec;
use Shlinkio\Shlink\Core\Domain\Spec\IsDomain;