Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ServiceLocatorTrait.php

function ServiceLocatorTrait::createNotFoundException

1 call to ServiceLocatorTrait::createNotFoundException()
ServiceLocatorTrait::get in vendor/symfony/service-contracts/ServiceLocatorTrait.php
1 method overrides ServiceLocatorTrait::createNotFoundException()
ServiceLocator::createNotFoundException in vendor/symfony/dependency-injection/ServiceLocator.php

File

vendor/symfony/service-contracts/ServiceLocatorTrait.php, line 87

Class

ServiceLocatorTrait
A trait to help implement ServiceProviderInterface.

Namespace

Symfony\Contracts\Service

Code

private function createNotFoundException(string $id) : NotFoundExceptionInterface {
    if (!($alternatives = array_keys($this->factories))) {
        $message = 'is empty...';
    }
    else {
        $last = array_pop($alternatives);
        if ($alternatives) {
            $message = sprintf('only knows about the "%s" and "%s" services.', implode('", "', $alternatives), $last);
        }
        else {
            $message = sprintf('only knows about the "%s" service.', $last);
        }
    }
    if ($this->loading) {
        $message = sprintf('The service "%s" has a dependency on a non-existent service "%s". This locator %s', end($this->loading), $id, $message);
    }
    else {
        $message = sprintf('Service "%s" not found: the current service locator %s', $id, $message);
    }
    return new class ($message) extends \InvalidArgumentException implements NotFoundExceptionInterface {

};
}
RSS feed
Powered by Drupal