Applied API role specs to short URL creation

This commit is contained in:
Alejandro Celaya
2021-01-04 20:15:42 +01:00
parent 19834f6715
commit 4b67d41362
15 changed files with 314 additions and 7 deletions

View File

@@ -8,6 +8,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Shlinkio\Shlink\Core\Domain\Model\DomainItem;
use Shlinkio\Shlink\Core\Domain\Repository\DomainRepositoryInterface;
use Shlinkio\Shlink\Core\Entity\Domain;
use Shlinkio\Shlink\Core\Exception\DomainNotFoundException;
use Shlinkio\Shlink\Rest\ApiKey\Role;
use Shlinkio\Shlink\Rest\Entity\ApiKey;
@@ -43,4 +44,15 @@ class DomainService implements DomainServiceInterface
...$mappedDomains,
];
}
public function getDomain(string $domainId): Domain
{
/** @var Domain|null $domain */
$domain = $this->em->find(Domain::class, $domainId);
if ($domain === null) {
throw DomainNotFoundException::fromId($domainId);
}
return $domain;
}
}