mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 23:33:13 +08:00
Extended DomainNotFoundException to allow creating from an authority
This commit is contained in:
committed by
Alejandro Celaya
parent
4ef5ab7a90
commit
2ac7be4363
@@ -17,16 +17,27 @@ class DomainNotFoundException extends DomainException implements ProblemDetailsE
|
||||
private const TITLE = 'Domain not found';
|
||||
private const TYPE = 'DOMAIN_NOT_FOUND';
|
||||
|
||||
private function __construct(string $message, array $additional)
|
||||
{
|
||||
parent::__construct($message);
|
||||
|
||||
$this->detail = $message;
|
||||
$this->title = self::TITLE;
|
||||
$this->type = self::TYPE;
|
||||
$this->status = StatusCodeInterface::STATUS_NOT_FOUND;
|
||||
$this->additional = $additional;
|
||||
}
|
||||
|
||||
public static function fromId(string $id): self
|
||||
{
|
||||
$e = new self(sprintf('Domain with id "%s" could not be found', $id));
|
||||
return new self(sprintf('Domain with id "%s" could not be found', $id), ['id' => $id]);
|
||||
}
|
||||
|
||||
$e->detail = $e->getMessage();
|
||||
$e->title = self::TITLE;
|
||||
$e->type = self::TYPE;
|
||||
$e->status = StatusCodeInterface::STATUS_NOT_FOUND;
|
||||
$e->additional = ['id' => $id];
|
||||
|
||||
return $e;
|
||||
public static function fromAuthority(string $authority): self
|
||||
{
|
||||
return new self(
|
||||
sprintf('Domain with authority "%s" could not be found', $authority),
|
||||
['authority' => $authority],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user