98 lines
3.5 KiB
YAML
98 lines
3.5 KiB
YAML
name: ServiceLocator
|
|
class_comment: '# * @author Robin Chalas <robin.chalas@gmail.com>
|
|
|
|
# * @author Nicolas Grekas <p@tchwork.com>
|
|
|
|
# *
|
|
|
|
# * @template-covariant T of mixed
|
|
|
|
# *
|
|
|
|
# * @implements ServiceCollectionInterface<T>'
|
|
dependencies:
|
|
- name: ContainerExceptionInterface
|
|
type: class
|
|
source: Psr\Container\ContainerExceptionInterface
|
|
- name: NotFoundExceptionInterface
|
|
type: class
|
|
source: Psr\Container\NotFoundExceptionInterface
|
|
- name: RuntimeException
|
|
type: class
|
|
source: Symfony\Component\DependencyInjection\Exception\RuntimeException
|
|
- name: ServiceCircularReferenceException
|
|
type: class
|
|
source: Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
|
|
- name: ServiceNotFoundException
|
|
type: class
|
|
source: Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
|
|
- name: ServiceCollectionInterface
|
|
type: class
|
|
source: Symfony\Contracts\Service\ServiceCollectionInterface
|
|
- name: ServiceLocatorTrait
|
|
type: class
|
|
source: Symfony\Contracts\Service\ServiceLocatorTrait
|
|
- name: ServiceSubscriberInterface
|
|
type: class
|
|
source: Symfony\Contracts\Service\ServiceSubscriberInterface
|
|
properties: []
|
|
methods:
|
|
- name: withContext
|
|
visibility: public
|
|
parameters:
|
|
- name: externalId
|
|
- name: container
|
|
comment: "# * @author Robin Chalas <robin.chalas@gmail.com>\n# * @author Nicolas\
|
|
\ Grekas <p@tchwork.com>\n# *\n# * @template-covariant T of mixed\n# *\n# * @implements\
|
|
\ ServiceCollectionInterface<T>\n# */\n# class ServiceLocator implements ServiceCollectionInterface\n\
|
|
# {\n# use ServiceLocatorTrait {\n# get as private doGet;\n# }\n# \n# private\
|
|
\ ?string $externalId = null;\n# private ?Container $container = null;\n# \n#\
|
|
\ public function get(string $id): mixed\n# {\n# if (!$this->externalId) {\n#\
|
|
\ return $this->doGet($id);\n# }\n# \n# try {\n# return $this->doGet($id);\n#\
|
|
\ } catch (RuntimeException $e) {\n# $what = \\sprintf('service \"%s\" required\
|
|
\ by \"%s\"', $id, $this->externalId);\n# $message = preg_replace('/service \"\
|
|
\\.service_locator\\.[^\"]++\"/', $what, $e->getMessage());\n# \n# if ($e->getMessage()\
|
|
\ === $message) {\n# $message = \\sprintf('Cannot resolve %s: %s', $what, $message);\n\
|
|
# }\n# \n# $r = new \\ReflectionProperty($e, 'message');\n# $r->setValue($e, $message);\n\
|
|
# \n# throw $e;\n# }\n# }\n# \n# public function __invoke(string $id): mixed\n\
|
|
# {\n# return isset($this->factories[$id]) ? $this->get($id) : null;\n# }\n# \n\
|
|
# /**\n# * @internal"
|
|
- name: count
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: getIterator
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: createNotFoundException
|
|
visibility: private
|
|
parameters:
|
|
- name: id
|
|
comment: null
|
|
- name: createCircularReferenceException
|
|
visibility: private
|
|
parameters:
|
|
- name: id
|
|
- name: path
|
|
comment: null
|
|
- name: formatAlternatives
|
|
visibility: private
|
|
parameters:
|
|
- name: alternatives
|
|
default: 'null'
|
|
- name: separator
|
|
default: '''and'''
|
|
comment: null
|
|
traits:
|
|
- Psr\Container\ContainerExceptionInterface
|
|
- Psr\Container\NotFoundExceptionInterface
|
|
- Symfony\Component\DependencyInjection\Exception\RuntimeException
|
|
- Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
|
|
- Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
|
|
- Symfony\Contracts\Service\ServiceCollectionInterface
|
|
- Symfony\Contracts\Service\ServiceLocatorTrait
|
|
- Symfony\Contracts\Service\ServiceSubscriberInterface
|
|
interfaces:
|
|
- ServiceCollectionInterface
|
|
- ServiceCollectionInterface
|