0 follower

Final Class Yiisoft\Di\NotFoundException

InheritanceYiisoft\Di\NotFoundException » Exception
ImplementsPsr\Container\NotFoundExceptionInterface, Yiisoft\FriendlyException\FriendlyExceptionInterface

NotFoundException is thrown when no definition or class was found in the container for a given ID.

Method Details

Hide inherited methods

__construct() public method

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);
}

            
getBuildStack() public method

public string[] getBuildStack ( )

                public function getBuildStack(): array
{
    return $this->buildStack;
}

            
getId() public method

public string getId ( )

                public function getId(): string
{
    return $this->id;
}

            
getName() public method

public string getName ( )

                public function getName(): string
{
    return sprintf('No definition or class found for "%s" ID.', $this->id);
}

            
getSolution() public method

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);
}