PhpArrayContainer
class PhpArrayContainer extends Container (View source)
Provides a container optimized for Drupal's needs.
This container implementation is compatible with the default Symfony dependency injection container and similar to the Symfony ContainerBuilder class, but optimized for speed.
It is based on a human-readable PHP array container definition with a structure very similar to the YAML container definition.
Properties
| protected array | $parameters | The parameters of the container. |
from Container |
| protected array | $aliases | The aliases of the container. |
from Container |
| protected array | $serviceDefinitions | The service definitions of the container. |
from Container |
| protected array | $services | The instantiated services. |
from Container |
| protected array | $privateServices | The instantiated private services. |
from Container |
| protected array | $loading | The currently loading services. |
from Container |
| protected bool | $frozen | Whether the container parameters can still be changed. |
from Container |
Methods
Constructs a new Container instance.
{@inheritdoc}
Creates a service from a service definition.
Resolves arguments that represent services or variables to the real values.
Provides alternatives for a given array and key.
Provides alternatives in case a service was not found.
Provides alternatives in case a parameter was not found.
Details
__construct(array $container_definition = [])
Constructs a new Container instance.
get($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE)
{@inheritdoc}
reset()
Resets shared services from the container.
The container is not intended to be used again after being reset in a normal workflow. This method is meant as a way to release references for ref-counting. A subsequent call to ContainerInterface::get() will recreate a new instance of the shared service.
protected object
createService(array $definition, string $id)
Creates a service from a service definition.
set($id, $service)
{@inheritdoc}
has($id)
{@inheritdoc}
getParameter($name)
{@inheritdoc}
hasParameter($name)
{@inheritdoc}
setParameter($name, $value)
{@inheritdoc}
initialized($id)
{@inheritdoc}
protected array
resolveServicesAndParameters(array|object $arguments)
Resolves arguments that represent services or variables to the real values.
protected string[]
getAlternatives(string $search_key, array $keys)
Provides alternatives for a given array and key.
protected string[]
getServiceAlternatives(string $id)
Provides alternatives in case a service was not found.
protected string[]
getParameterAlternatives(string $name)
Provides alternatives in case a parameter was not found.
array
getServiceIds()
Gets all defined service IDs.