mailpoet
/
vendor-prefixed
/
symfony
/
dependency-injection
/
Exception
/
ServiceNotFoundException.php
AutowiringFailedException.php
2 years ago
BadMethodCallException.php
4 years ago
EnvNotFoundException.php
4 years ago
EnvParameterException.php
2 years ago
ExceptionInterface.php
4 years ago
InvalidArgumentException.php
4 years ago
InvalidParameterTypeException.php
4 years ago
LogicException.php
4 years ago
OutOfBoundsException.php
4 years ago
ParameterCircularReferenceException.php
2 years ago
ParameterNotFoundException.php
2 years ago
RuntimeException.php
4 years ago
ServiceCircularReferenceException.php
2 years ago
ServiceNotFoundException.php
2 years ago
index.php
3 years ago
ServiceNotFoundException.php
45 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\DependencyInjection\Exception; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Psr\Container\NotFoundExceptionInterface; |
| 5 | class ServiceNotFoundException extends InvalidArgumentException implements NotFoundExceptionInterface |
| 6 | { |
| 7 | private $id; |
| 8 | private $sourceId; |
| 9 | private $alternatives; |
| 10 | public function __construct(string $id, ?string $sourceId = null, ?\Throwable $previous = null, array $alternatives = [], ?string $msg = null) |
| 11 | { |
| 12 | if (null !== $msg) { |
| 13 | // no-op |
| 14 | } elseif (null === $sourceId) { |
| 15 | $msg = \sprintf('You have requested a non-existent service "%s".', $id); |
| 16 | } else { |
| 17 | $msg = \sprintf('The service "%s" has a dependency on a non-existent service "%s".', $sourceId, $id); |
| 18 | } |
| 19 | if ($alternatives) { |
| 20 | if (1 == \count($alternatives)) { |
| 21 | $msg .= ' Did you mean this: "'; |
| 22 | } else { |
| 23 | $msg .= ' Did you mean one of these: "'; |
| 24 | } |
| 25 | $msg .= \implode('", "', $alternatives) . '"?'; |
| 26 | } |
| 27 | parent::__construct($msg, 0, $previous); |
| 28 | $this->id = $id; |
| 29 | $this->sourceId = $sourceId; |
| 30 | $this->alternatives = $alternatives; |
| 31 | } |
| 32 | public function getId() |
| 33 | { |
| 34 | return $this->id; |
| 35 | } |
| 36 | public function getSourceId() |
| 37 | { |
| 38 | return $this->sourceId; |
| 39 | } |
| 40 | public function getAlternatives() |
| 41 | { |
| 42 | return $this->alternatives; |
| 43 | } |
| 44 | } |
| 45 |