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 PHP array container definition dumped as a performance-optimized machine-readable format.
The best way to initialize this container is to use a Container Builder, compile it and then retrieve the definition via \Drupal\Component\DependencyInjection\Dumper\OptimizedPhpArrayDumper::getArray().
The retrieved array can be cached safely and then passed to this container via the constructor.
As the container is unfrozen by default, a second parameter can be passed to the container to "freeze" the parameter bag.
This container is different in behavior from the default Symfony container in the following ways:
Name | Modifiers | Type | Description |
---|---|---|---|
Container::$aliases | protected | property | The aliases of the container. |
Container::$frozen | protected | property | Whether the container parameters can still be changed. |
Container::$loading | protected | property | The currently loading services. |
Container::$parameters | protected | property | The parameters of the container. |
Container::$privateServices | protected | property | The instantiated private services. |
Container::$serviceDefinitions | protected | property | The service definitions of the container. |
Container::$services | protected | property | The instantiated services. |
Container::addScope | public | function | |
Container::createService | protected | function | Creates a service from a service definition. |
Container::enterScope | public | function | |
Container::get | public | function | |
Container::getAlternatives | protected | function | Provides alternatives for a given array and key. |
Container::getParameter | public | function | |
Container::getParameterAlternatives | protected | function | Provides alternatives in case a parameter was not found. |
Container::getServiceAlternatives | protected | function | Provides alternatives in case a service was not found. |
Container::getServiceIds | public | function | Gets all defined service IDs. |
Container::has | public | function | |
Container::hasParameter | public | function | |
Container::hasScope | public | function | |
Container::initialized | public | function | Check for whether or not a service has been initialized. Overrides IntrospectableContainerInterface::initialized |
Container::isScopeActive | public | function | |
Container::leaveScope | public | function | |
Container::reset | public | function | Resets shared services from the container. Overrides ResettableContainerInterface::reset |
Container::resolveServicesAndParameters | protected | function | Resolves arguments that represent services or variables to the real values. |
Container::set | public | function | |
Container::setParameter | public | function | |
Container::__clone | private | function | Ensure that cloning doesn't work. |
Container::__construct | public | function | Constructs a new Container instance. |
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!DependencyInjection!Container.php/class/Container/8.1.x