Final Class Yiisoft\Di\NotFoundException
| Inheritance | Yiisoft\Di\NotFoundException » Exception |
|---|---|
| Implements | Psr\Container\NotFoundExceptionInterface, Yiisoft\FriendlyException\FriendlyExceptionInterface |
NotFoundException is thrown when no definition or class was found in the container for a given ID.
Public Methods
Method Details
| public mixed __construct ( string $id, string[] $buildStack = [], Throwable|null $previous = null ) | ||
| $id | string |
ID of the definition or name of the class that was not found. |
| $buildStack | string[] |
Stack of IDs of services requested definition or class that was not found. |
| $previous | Throwable|null | |
public function __construct(
private readonly string $id,
private array $buildStack = [],
?Throwable $previous = null,
) {
if (empty($this->buildStack)) {
$message = sprintf('No definition or class found or resolvable for "%s".', $id);
} elseif ($this->buildStack === [$id]) {
$message = sprintf('No definition or class found or resolvable for "%s" while building it.', $id);
} else {
$message = sprintf(
'No definition or class found or resolvable for "%s" while building "%s".',
end($this->buildStack),
implode('" -> "', $buildStack),
);
}
parent::__construct($message, previous: $previous);
}
| public string[] getBuildStack ( ) |
public function getBuildStack(): array
{
return $this->buildStack;
}
| public string getName ( ) |
public function getName(): string
{
return sprintf('No definition or class found for "%s" ID.', $this->id);
}
| public string|null getSolution ( ) |
public function getSolution(): ?string
{
$solution = <<<SOLUTION
Ensure that either a service with ID "%1\$s" is defined or such class exists and is autoloadable.
SOLUTION;
return sprintf($solution, $this->id);
}
Signup or Login in order to comment.