mailpoet
/
vendor-prefixed
/
symfony
/
dependency-injection
/
Exception
/
ParameterNotFoundException.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
ParameterNotFoundException.php
65 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\DependencyInjection\Exception; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Psr\Container\NotFoundExceptionInterface; |
| 5 | class ParameterNotFoundException extends InvalidArgumentException implements NotFoundExceptionInterface |
| 6 | { |
| 7 | private $key; |
| 8 | private $sourceId; |
| 9 | private $sourceKey; |
| 10 | private $alternatives; |
| 11 | private $nonNestedAlternative; |
| 12 | public function __construct(string $key, ?string $sourceId = null, ?string $sourceKey = null, ?\Throwable $previous = null, array $alternatives = [], ?string $nonNestedAlternative = null) |
| 13 | { |
| 14 | $this->key = $key; |
| 15 | $this->sourceId = $sourceId; |
| 16 | $this->sourceKey = $sourceKey; |
| 17 | $this->alternatives = $alternatives; |
| 18 | $this->nonNestedAlternative = $nonNestedAlternative; |
| 19 | parent::__construct('', 0, $previous); |
| 20 | $this->updateRepr(); |
| 21 | } |
| 22 | public function updateRepr() |
| 23 | { |
| 24 | if (null !== $this->sourceId) { |
| 25 | $this->message = \sprintf('The service "%s" has a dependency on a non-existent parameter "%s".', $this->sourceId, $this->key); |
| 26 | } elseif (null !== $this->sourceKey) { |
| 27 | $this->message = \sprintf('The parameter "%s" has a dependency on a non-existent parameter "%s".', $this->sourceKey, $this->key); |
| 28 | } else { |
| 29 | $this->message = \sprintf('You have requested a non-existent parameter "%s".', $this->key); |
| 30 | } |
| 31 | if ($this->alternatives) { |
| 32 | if (1 == \count($this->alternatives)) { |
| 33 | $this->message .= ' Did you mean this: "'; |
| 34 | } else { |
| 35 | $this->message .= ' Did you mean one of these: "'; |
| 36 | } |
| 37 | $this->message .= \implode('", "', $this->alternatives) . '"?'; |
| 38 | } elseif (null !== $this->nonNestedAlternative) { |
| 39 | $this->message .= ' You cannot access nested array items, do you want to inject "' . $this->nonNestedAlternative . '" instead?'; |
| 40 | } |
| 41 | } |
| 42 | public function getKey() |
| 43 | { |
| 44 | return $this->key; |
| 45 | } |
| 46 | public function getSourceId() |
| 47 | { |
| 48 | return $this->sourceId; |
| 49 | } |
| 50 | public function getSourceKey() |
| 51 | { |
| 52 | return $this->sourceKey; |
| 53 | } |
| 54 | public function setSourceId(?string $sourceId) |
| 55 | { |
| 56 | $this->sourceId = $sourceId; |
| 57 | $this->updateRepr(); |
| 58 | } |
| 59 | public function setSourceKey(?string $sourceKey) |
| 60 | { |
| 61 | $this->sourceKey = $sourceKey; |
| 62 | $this->updateRepr(); |
| 63 | } |
| 64 | } |
| 65 |