class ContainerBuilder
Same name in this branch
- 11.1.x vendor/symfony/dependency-injection/ContainerBuilder.php \Symfony\Component\DependencyInjection\ContainerBuilder
Drupal's dependency injection container builder.
@todo Submit upstream patches to Symfony to not require these overrides.
Hierarchy
- class \Symfony\Component\DependencyInjection\Container implements \Symfony\Component\DependencyInjection\ContainerInterface, \Symfony\Contracts\Service\ResetInterface
- class \Symfony\Component\DependencyInjection\ContainerBuilder extends \Symfony\Component\DependencyInjection\Container implements \Symfony\Component\DependencyInjection\TaggedContainerInterface
- class \Drupal\Core\DependencyInjection\ContainerBuilder extends \Symfony\Component\DependencyInjection\ContainerBuilder implements \Drupal\Component\DependencyInjection\ContainerInterface
- class \Symfony\Component\DependencyInjection\ContainerBuilder extends \Symfony\Component\DependencyInjection\Container implements \Symfony\Component\DependencyInjection\TaggedContainerInterface
Expanded class hierarchy of ContainerBuilder
Related topics
- Services and Dependency Injection Container
- Overview of the Dependency Injection Container and Services.
19 files declare their use of ContainerBuilder
- ConfigOverride.php in core/
lib/ Drupal/ Core/ Installer/ ConfigOverride.php - CoreServiceProvider.php in core/
lib/ Drupal/ Core/ CoreServiceProvider.php - DrupalKernel.php in core/
lib/ Drupal/ Core/ DrupalKernel.php - FileServiceProvider.php in core/
modules/ file/ src/ FileServiceProvider.php - InlineFormErrorsServiceProvider.php in core/
modules/ inline_form_errors/ src/ InlineFormErrorsServiceProvider.php
File
-
core/
lib/ Drupal/ Core/ DependencyInjection/ ContainerBuilder.php, line 19
Namespace
Drupal\Core\DependencyInjectionView source
class ContainerBuilder extends SymfonyContainerBuilder implements ContainerInterface {
/**
* {@inheritdoc}
*/
public function __construct(?ParameterBagInterface $parameterBag = NULL) {
parent::__construct($parameterBag);
$this->setResourceTracking(FALSE);
}
/**
* Overrides Symfony\Component\DependencyInjection\ContainerBuilder::set().
*
* Drupal's container builder can be used at runtime after compilation, so we
* override Symfony's ContainerBuilder's restriction on setting services in a
* frozen builder.
*
* @todo Restrict this to synthetic services only. Ideally, the upstream
* ContainerBuilder class should be fixed to allow setting synthetic
* services in a frozen builder.
*/
public function set($id, $service) : void {
SymfonyContainer::set($id, $service);
}
/**
* {@inheritdoc}
*/
public function register($id, $class = NULL) : Definition {
$definition = new Definition($class);
// As of Symfony 5.2 all services are private by default, but in Drupal
// services are still public by default.
$definition->setPublic(TRUE);
return $this->setDefinition($id, $definition);
}
/**
* {@inheritdoc}
*/
public function setAlias($alias, $id) : Alias {
$alias = parent::setAlias($alias, $id);
// As of Symfony 3.4 all aliases are private by default.
$alias->setPublic(TRUE);
return $alias;
}
/**
* {@inheritdoc}
*/
public function setParameter($name, $value) : void {
if (strtolower($name) !== $name) {
throw new \InvalidArgumentException("Parameter names must be lowercase: {$name}");
}
parent::setParameter($name, $value);
}
/**
* {@inheritdoc}
*/
public function __sleep() : array {
assert(FALSE, 'The container was serialized.');
return array_keys(get_object_vars($this));
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
Container::$aliases | protected | property | |||
Container::$compiled | private | property | |||
Container::$envCache | private | property | |||
Container::$factories | protected | property | |||
Container::$fileMap | protected | property | |||
Container::$getEnv | private | property | 1 | ||
Container::$loading | protected | property | |||
Container::$make | private static | property | |||
Container::$methodMap | protected | property | |||
Container::$parameterBag | protected | property | |||
Container::$privates | protected | property | |||
Container::$resolving | protected | property | |||
Container::$services | protected | property | |||
Container::$syntheticIds | protected | property | |||
Container::camelize | public static | function | Camelizes a string. | ||
Container::getParameter | public | function | Gets a parameter. | Overrides ContainerInterface::getParameter | |
Container::getParameterBag | public | function | Gets the service container parameter bag. | ||
Container::getService | final protected | function | @internal | ||
Container::hasParameter | public | function | Overrides ContainerInterface::hasParameter | ||
Container::initialized | public | function | Returns true if the given service has actually been initialized. | Overrides ContainerInterface::initialized | |
Container::isCompiled | public | function | Returns true if the container is compiled. | ||
Container::load | protected | function | Creates a service by requiring its factory file. | ||
Container::make | private static | function | Creates a service. | ||
Container::reset | public | function | Overrides ResetInterface::reset | ||
Container::underscore | public static | function | A string to underscore. | ||
Container::__clone | private | function | |||
ContainerBuilder::$aliasDefinitions | private | property | |||
ContainerBuilder::$autoconfiguredAttributes | private | property | |||
ContainerBuilder::$autoconfiguredInstanceof | private | property | |||
ContainerBuilder::$classReflectors | private | property | |||
ContainerBuilder::$compiler | private | property | |||
ContainerBuilder::$definitions | private | property | |||
ContainerBuilder::$envCounters | private | property | |||
ContainerBuilder::$envPlaceholders | private | property | |||
ContainerBuilder::$expressionLanguage | private | property | |||
ContainerBuilder::$expressionLanguageProviders | private | property | |||
ContainerBuilder::$extensionConfigs | private | property | |||
ContainerBuilder::$extensions | private | property | |||
ContainerBuilder::$extensionsByNs | private | property | |||
ContainerBuilder::$pathsInVendor | private | property | |||
ContainerBuilder::$proxyInstantiator | private | property | |||
ContainerBuilder::$removedBindingIds | private | property | |||
ContainerBuilder::$removedIds | private | property | |||
ContainerBuilder::$resources | private | property | |||
ContainerBuilder::$trackResources | private | property | |||
ContainerBuilder::$usedTags | private | property | |||
ContainerBuilder::$vendors | private | property | |||
ContainerBuilder::addAliases | public | function | Adds the service aliases. | ||
ContainerBuilder::addCompilerPass | public | function | Adds a compiler pass. | 1 | |
ContainerBuilder::addDefinitions | public | function | Adds the service definitions. | ||
ContainerBuilder::addExpressionLanguageProvider | public | function | |||
ContainerBuilder::addObjectResource | public | function | Adds the object class hierarchy as resources. | ||
ContainerBuilder::addResource | public | function | |||
ContainerBuilder::autowire | public | function | Registers an autowired service definition. | ||
ContainerBuilder::callMethod | private | function | |||
ContainerBuilder::compile | public | function | Compiles the container. | Overrides Container::compile | 1 |
ContainerBuilder::createService | private | function | Creates a service for a service definition. | ||
ContainerBuilder::deprecateParameter | public | function | Deprecates a service container parameter. | ||
ContainerBuilder::doGet | private | function | |||
ContainerBuilder::doResolveServices | private | function | |||
ContainerBuilder::fileExists | public | function | Checks whether the requested file or directory exists and registers the result for resource tracking. | ||
ContainerBuilder::findDefinition | public | function | Gets a service definition by id or alias. | ||
ContainerBuilder::findTaggedServiceIds | public | function | Returns service ids for a given tag. | Overrides TaggedContainerInterface::findTaggedServiceIds | |
ContainerBuilder::findTags | public | function | Returns all tags the defined services use. | ||
ContainerBuilder::findUnusedTags | public | function | Returns all tags not queried by findTaggedServiceIds. | ||
ContainerBuilder::get | public | function | Overrides Container::get | ||
ContainerBuilder::getAlias | public | function | |||
ContainerBuilder::getAliases | public | function | |||
ContainerBuilder::getAutoconfiguredAttributes | public | function | |||
ContainerBuilder::getAutoconfiguredInstanceof | public | function | Returns an array of ChildDefinition[] keyed by interface. | ||
ContainerBuilder::getCompiler | public | function | Returns the compiler. | ||
ContainerBuilder::getCompilerPassConfig | public | function | Returns the compiler pass config which can then be modified. | ||
ContainerBuilder::getDefinition | public | function | Gets a service definition. | ||
ContainerBuilder::getDefinitions | public | function | Gets all service definitions. | ||
ContainerBuilder::getEnv | protected | function | Fetches a variable from the environment. | Overrides Container::getEnv | |
ContainerBuilder::getEnvCounters | public | function | Get statistics about env usage. | ||
ContainerBuilder::getExpressionLanguage | private | function | |||
ContainerBuilder::getExpressionLanguageProviders | public | function | |||
ContainerBuilder::getExtension | public | function | Returns an extension by alias or namespace. | ||
ContainerBuilder::getExtensionConfig | public | function | Returns the configuration array for the given extension. | ||
ContainerBuilder::getExtensions | public | function | Returns all registered extensions. | ||
ContainerBuilder::getInitializedConditionals | public static | function | @internal | ||
ContainerBuilder::getReflectionClass | public | function | Retrieves the requested reflection class and registers it for resource tracking. | ||
ContainerBuilder::getRemovedBindingIds | public | function | Gets removed binding ids. | ||
ContainerBuilder::getRemovedIds | public | function | Gets removed service or alias ids. | Overrides Container::getRemovedIds | |
ContainerBuilder::getResources | public | function | Returns an array of resources loaded to build this configuration. | ||
ContainerBuilder::getServiceConditionals | public static | function | @internal | ||
ContainerBuilder::getServiceIds | public | function | Gets all service ids. | Overrides Container::getServiceIds | |
ContainerBuilder::has | public | function | Returns true if the container can return an entry for the given identifier. Returns false otherwise. |
Overrides Container::has | |
ContainerBuilder::hasAlias | public | function | |||
ContainerBuilder::hasDefinition | public | function | Returns true if a service definition exists under the given identifier. | ||
ContainerBuilder::hasExtension | public | function | Checks if we have an extension. | ||
ContainerBuilder::hash | public static | function | Computes a reasonably unique hash of a serializable value. | ||
ContainerBuilder::INTERNAL_TYPES | private | constant | |||
ContainerBuilder::inVendors | private | function | |||
ContainerBuilder::isTrackingResources | public | function | Checks if resources are tracked. | ||
ContainerBuilder::loadFromExtension | public | function | Loads the configuration for an extension. | ||
ContainerBuilder::log | public | function | @final | ||
ContainerBuilder::merge | public | function | Merges a ContainerBuilder with the current ContainerBuilder configuration. | ||
ContainerBuilder::parameterCannotBeEmpty | public | function | |||
ContainerBuilder::prependExtensionConfig | public | function | Prepends a config array to the configs of the given extension. | ||
ContainerBuilder::register | public | function | Registers a service definition. | Overrides ContainerBuilder::register | |
ContainerBuilder::registerAliasForArgument | public | function | Registers an autowiring alias that only binds to a specific argument name. | ||
ContainerBuilder::registerAttributeForAutoconfiguration | public | function | Registers an attribute that will be used for autoconfiguring annotated classes. | ||
ContainerBuilder::registerChild | public | function | This method provides a fluid interface for easily registering a child service definition of the given parent service. |
||
ContainerBuilder::registerExtension | public | function | 1 | ||
ContainerBuilder::registerForAutoconfiguration | public | function | Returns a ChildDefinition that will be used for autoconfiguring the interface/class. | ||
ContainerBuilder::removeAlias | public | function | |||
ContainerBuilder::removeBindings | public | function | Removes bindings for a service. | ||
ContainerBuilder::removeDefinition | public | function | Removes a service definition. | ||
ContainerBuilder::resolveEnvPlaceholders | public | function | Resolves env parameter placeholders in a string or an array. | 1 | |
ContainerBuilder::resolveServices | public | function | Replaces service references by the real service instance and evaluates expressions. | ||
ContainerBuilder::set | public | function | Overrides Symfony\Component\DependencyInjection\ContainerBuilder::set(). | Overrides ContainerBuilder::set | |
ContainerBuilder::setAlias | public | function | Sets an alias for an existing service. | Overrides ContainerBuilder::setAlias | |
ContainerBuilder::setAliases | public | function | Sets the service aliases. | ||
ContainerBuilder::setDefinition | public | function | Sets a service definition. | ||
ContainerBuilder::setDefinitions | public | function | Sets the service definitions. | ||
ContainerBuilder::setParameter | public | function | Overrides Container::setParameter | ||
ContainerBuilder::setProxyInstantiator | public | function | Sets the instantiator to be used when fetching proxies. | ||
ContainerBuilder::setResources | public | function | Sets the resources for this configuration. | ||
ContainerBuilder::setResourceTracking | public | function | Sets the track resources flag. | ||
ContainerBuilder::shareService | private | function | |||
ContainerBuilder::willBeAvailable | final public static | function | Checks whether a class is available and will remain available in the "no-dev" mode of Composer. | ||
ContainerBuilder::__construct | public | function | Overrides ContainerBuilder::__construct | ||
ContainerBuilder::__sleep | public | function | |||
ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE | public | constant | |||
ContainerInterface::IGNORE_ON_INVALID_REFERENCE | public | constant | |||
ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE | public | constant | |||
ContainerInterface::NULL_ON_INVALID_REFERENCE | public | constant | |||
ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE | public | constant |