class MergeExtensionConfigurationContainerBuilder extends ContainerBuilder
A container builder preventing using methods that wouldn't have any effect from extensions.
protected | $parameterBag | from Container | |
protected | $services | from Container | |
protected | $fileMap | from Container | |
protected | $methodMap | from Container | |
protected | $factories | from Container | |
protected | $aliases | from Container | |
protected | $loading | from Container | |
protected | $resolving | from Container | |
protected | $syntheticIds | from Container |
__construct(ExtensionInterface $extension, ParameterBagInterface $parameterBag = null) | ||
compile(bool $resolveEnvPlaceholders = false) Compiles the container. | ||
bool | isCompiled() Returns true if the container is compiled. | from Container |
ParameterBagInterface | getParameterBag() Gets the service container parameter bag. | from Container |
mixed | getParameter(string $name) Gets a parameter. | from Container |
bool | hasParameter(string $name) Checks if a parameter exists. | from Container |
setParameter(string $name, mixed $value) Sets a parameter. | from Container | |
set(string $id, object $service) Sets a service. | from ContainerBuilder | |
bool | has(string $id) Returns true if the given service is defined. | from ContainerBuilder |
object | get(string $id, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) Gets a service. | from ContainerBuilder |
bool | initialized(string $id) Returns true if the given service has actually been initialized. | from Container |
reset() Resets shared services from the container. | from Container | |
array | getServiceIds() Gets all service ids. | from ContainerBuilder |
array | getRemovedIds() Gets removed service or alias ids. | from ContainerBuilder |
static string | camelize(string $id) Camelizes a string. | from Container |
static string | underscore(string $id) A string to underscore. | from Container |
object | load($file) Creates a service by requiring its factory file. | from Container |
mixed | getEnv(string $name) Fetches a variable from the environment. | from ContainerBuilder |
setResourceTracking(bool $track) Sets the track resources flag. | from ContainerBuilder | |
bool | isTrackingResources() Checks if resources are tracked. | from ContainerBuilder |
setProxyInstantiator(InstantiatorInterface $proxyInstantiator) Sets the instantiator to be used when fetching proxies. | from ContainerBuilder | |
registerExtension(ExtensionInterface $extension) | ||
ExtensionInterface | getExtension(string $name) Returns an extension by alias or namespace. | from ContainerBuilder |
ExtensionInterface[] | getExtensions() Returns all registered extensions. | from ContainerBuilder |
bool | hasExtension(string $name) Checks if we have an extension. | from ContainerBuilder |
ResourceInterface[] | getResources() Returns an array of resources loaded to build this configuration. | from ContainerBuilder |
$this | addResource(ResourceInterface $resource) | from ContainerBuilder |
$this | setResources(array $resources) Sets the resources for this configuration. | from ContainerBuilder |
$this | addObjectResource(object|string $object) Adds the object class hierarchy as resources. | from ContainerBuilder |
ReflectionClass|null | getReflectionClass(string|null $class, bool $throw = true) Retrieves the requested reflection class and registers it for resource tracking. | from ContainerBuilder |
bool | fileExists(string $path, bool|string $trackContents = true) Checks whether the requested file or directory exists and registers the result for resource tracking. | from ContainerBuilder |
$this | loadFromExtension(string $extension, array $values = null) Loads the configuration for an extension. | from ContainerBuilder |
$this | addCompilerPass(CompilerPassInterface $pass, string $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0) Adds a compiler pass. | |
PassConfig | getCompilerPassConfig() Returns the compiler pass config which can then be modified. | from ContainerBuilder |
Compiler | getCompiler() Returns the compiler. | from ContainerBuilder |
removeDefinition(string $id) Removes a service definition. | from ContainerBuilder | |
merge(ContainerBuilder $container) Merges a ContainerBuilder with the current ContainerBuilder configuration. | from ContainerBuilder | |
array | getExtensionConfig(string $name) Returns the configuration array for the given extension. | from ContainerBuilder |
prependExtensionConfig(string $name, array $config) Prepends a config array to the configs of the given extension. | from ContainerBuilder | |
addAliases(array $aliases) Adds the service aliases. | from ContainerBuilder | |
setAliases(array $aliases) Sets the service aliases. | from ContainerBuilder | |
Alias | setAlias(string $alias, string|Alias $id) Sets an alias for an existing service. | from ContainerBuilder |
removeAlias(string $alias) Removes an alias. | from ContainerBuilder | |
bool | hasAlias(string $id) Returns true if an alias exists under the given identifier. | from ContainerBuilder |
Alias[] | getAliases() Gets all defined aliases. | from ContainerBuilder |
Alias | getAlias(string $id) Gets an alias. | from ContainerBuilder |
Definition | register($id, $class = null) Registers a service definition. | from ContainerBuilder |
Definition | autowire(string $id, string|null $class = null) Registers an autowired service definition. | from ContainerBuilder |
addDefinitions(array $definitions) Adds the service definitions. | from ContainerBuilder | |
setDefinitions(array $definitions) Sets the service definitions. | from ContainerBuilder | |
Definition[] | getDefinitions() Gets all service definitions. | from ContainerBuilder |
Definition | setDefinition(string $id, Definition $definition) Sets a service definition. | from ContainerBuilder |
bool | hasDefinition(string $id) Returns true if a service definition exists under the given identifier. | from ContainerBuilder |
Definition | getDefinition(string $id) Gets a service definition. | from ContainerBuilder |
Definition | findDefinition(string $id) Gets a service definition by id or alias. | from ContainerBuilder |
mixed | resolveServices(mixed $value) Replaces service references by the real service instance and evaluates expressions. | from ContainerBuilder |
array | findTaggedServiceIds(string $name, bool $throwOnAbstract = false) Returns service ids for a given tag. | from ContainerBuilder |
array | findTags() Returns all tags the defined services use. | from ContainerBuilder |
string[] | findUnusedTags() Returns all tags not queried by findTaggedServiceIds. | from ContainerBuilder |
addExpressionLanguageProvider(ExpressionFunctionProviderInterface $provider) | from ContainerBuilder | |
ExpressionFunctionProviderInterface[] | getExpressionLanguageProviders() | from ContainerBuilder |
ChildDefinition | registerForAutoconfiguration(string $interface) Returns a ChildDefinition that will be used for autoconfiguring the interface/class. | from ContainerBuilder |
ChildDefinition[] | getAutoconfiguredInstanceof() Returns an array of ChildDefinition[] keyed by interface. | from ContainerBuilder |
mixed | resolveEnvPlaceholders(mixed $value, string|true|null $format = null, array $usedEnvs = null) Resolves env parameter placeholders in a string or an array. | |
int[] | getEnvCounters() Get statistics about env usage. | from ContainerBuilder |
log(CompilerPassInterface $pass, string $message) | from ContainerBuilder | |
static array | getServiceConditionals(mixed $value) Returns the Service Conditionals. | from ContainerBuilder |
static array | getInitializedConditionals(mixed $value) Returns the initialized conditionals. | from ContainerBuilder |
static string | hash(mixed $value) Computes a reasonably unique hash of a value. | from ContainerBuilder |
ExtensionInterface | $extension | |
ParameterBagInterface | $parameterBag |
Compiles the container.
This method passes the container to compiler passes whose job is to manipulate and optimize the container.
The main compiler passes roughly do four things:
bool | $resolveEnvPlaceholders | Whether %env()% parameters should be resolved using the current env vars or be replaced by uniquely identifiable placeholders. Set to "true" when you want to use the current ContainerBuilder directly, keep to "false" when the container is dumped instead. |
Returns true if the container is compiled.
bool |
Gets the service container parameter bag.
ParameterBagInterface | A ParameterBagInterface instance |
Gets a parameter.
string | $name | The parameter name |
mixed | The parameter value |
InvalidArgumentException | if the parameter is not defined |
Checks if a parameter exists.
string | $name | The parameter name |
bool | The presence of parameter in container |
Sets a parameter.
string | $name | The parameter name |
mixed | $value | The parameter value |
Sets a service.
string | $id | The service identifier |
object | $service | The service instance |
BadMethodCallException | When this ContainerBuilder is compiled |
Returns true if the given service is defined.
string | $id | The service identifier |
bool | true if the service is defined, false otherwise |
Gets a service.
string | $id | The service identifier |
int | $invalidBehavior | The behavior when the service does not exist |
object | The associated service |
InvalidArgumentException | when no definitions are available |
ServiceCircularReferenceException | When a circular reference is detected |
ServiceNotFoundException | When the service is not defined |
Exception |
Reference |
Returns true if the given service has actually been initialized.
string | $id |
bool | true if the service has been initialized, false otherwise |
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.
Gets all service ids.
array | An array of all defined service ids |
Gets removed service or alias ids.
array |
Camelizes a string.
string | $id | A string to camelize |
string | The camelized string |
A string to underscore.
string | $id | The string to underscore |
string | The underscored string |
Creates a service by requiring its factory file.
$file |
object | The service created by the file |
Fetches a variable from the environment.
string | $name | The name of the environment variable |
mixed | The value to use for the provided environment variable name |
EnvNotFoundException | When the environment variable is not found and has no default value |
Sets the track resources flag.
If you are not using the loaders and therefore don't want to depend on the Config component, set this flag to false.
bool | $track | True if you want to track resources, false otherwise |
Checks if resources are tracked.
bool | true If resources are tracked, false otherwise |
Sets the instantiator to be used when fetching proxies.
InstantiatorInterface | $proxyInstantiator |
ExtensionInterface | $extension |
Returns an extension by alias or namespace.
string | $name | An alias or a namespace |
ExtensionInterface | An extension instance |
LogicException | if the extension is not registered |
Returns all registered extensions.
ExtensionInterface[] | An array of ExtensionInterface |
Checks if we have an extension.
string | $name | The name of the extension |
bool | If the extension exists |
Returns an array of resources loaded to build this configuration.
ResourceInterface[] | An array of resources |
ResourceInterface | $resource |
$this |
Sets the resources for this configuration.
array | $resources | An array of resources |
$this |
Adds the object class hierarchy as resources.
object|string | $object | An object instance or class name |
$this |
Retrieves the requested reflection class and registers it for resource tracking.
string|null | $class | |
bool | $throw |
ReflectionClass|null |
ReflectionException | when a parent class/interface/trait is not found and $throw is true |
Checks whether the requested file or directory exists and registers the result for resource tracking.
string | $path | The file or directory path for which to check the existence |
bool|string | $trackContents | Whether to track contents of the given resource. If a string is passed, it will be used as pattern for tracking contents of the requested directory |
bool |
Loads the configuration for an extension.
string | $extension | The extension alias or namespace |
array | $values | An array of values that customizes the extension |
$this |
BadMethodCallException | When this ContainerBuilder is compiled |
LogicException | if the extension is not registered |
Adds a compiler pass.
CompilerPassInterface | $pass | A compiler pass |
string | $type | The type of compiler pass |
int | $priority | Used to sort the passes |
$this |
Returns the compiler pass config which can then be modified.
PassConfig | The compiler pass config |
Returns the compiler.
Compiler | The compiler |
Removes a service definition.
string | $id | The service identifier |
Merges a ContainerBuilder with the current ContainerBuilder configuration.
Service definitions overrides the current defined ones.
But for parameters, they are overridden by the current ones. It allows the parameters passed to the container constructor to have precedence over the loaded ones.
$container = new ContainerBuilder(new ParameterBag(array('foo' => 'bar')));
$loader = new LoaderXXX($container);
$loader->load('resource_name');
$container->register('foo', 'stdClass');
In the above example, even if the loaded resource defines a foo parameter, the value will still be 'bar' as defined in the ContainerBuilder constructor.
ContainerBuilder | $container |
BadMethodCallException | When this ContainerBuilder is compiled |
Returns the configuration array for the given extension.
string | $name | The name of the extension |
array | An array of configuration |
Prepends a config array to the configs of the given extension.
string | $name | The name of the extension |
array | $config | The config to set |
Adds the service aliases.
array | $aliases |
Sets the service aliases.
array | $aliases |
Sets an alias for an existing service.
string | $alias | The alias to create |
string|Alias | $id | The service to alias |
Alias |
InvalidArgumentException | if the id is not a string or an Alias |
InvalidArgumentException | if the alias is for itself |
Removes an alias.
string | $alias | The alias to remove |
Returns true if an alias exists under the given identifier.
string | $id | The service identifier |
bool | true if the alias exists, false otherwise |
Gets all defined aliases.
Alias[] | An array of aliases |
Gets an alias.
string | $id | The service identifier |
Alias | An Alias instance |
InvalidArgumentException | if the alias does not exist |
Registers a service definition.
This methods allows for simple registration of service definition with a fluid interface.
$id | ||
$class |
Definition | A Definition instance |
Registers an autowired service definition.
This method implements a shortcut for using setDefinition() with an autowired definition.
string | $id | The service identifier |
string|null | $class | The service class |
Definition | The created definition |
Adds the service definitions.
array | $definitions | An array of service definitions |
Sets the service definitions.
array | $definitions | An array of service definitions |
Gets all service definitions.
Definition[] | An array of Definition instances |
Sets a service definition.
string | $id | The service identifier |
Definition | $definition | A Definition instance |
Definition | the service definition |
BadMethodCallException | When this ContainerBuilder is compiled |
Returns true if a service definition exists under the given identifier.
string | $id | The service identifier |
bool | true if the service definition exists, false otherwise |
Gets a service definition.
string | $id | The service identifier |
Definition | A Definition instance |
ServiceNotFoundException | if the service definition does not exist |
Gets a service definition by id or alias.
The method "unaliases" recursively to return a Definition instance.
string | $id | The service identifier or alias |
Definition | A Definition instance |
ServiceNotFoundException | if the service definition does not exist |
Replaces service references by the real service instance and evaluates expressions.
mixed | $value | A value |
mixed | The same value with all service references replaced by the real service instances and all expressions evaluated |
Returns service ids for a given tag.
Example:
$container->register('foo')->addTag('my.tag', array('hello' => 'world'));
$serviceIds = $container->findTaggedServiceIds('my.tag');
foreach ($serviceIds as $serviceId => $tags) {
foreach ($tags as $tag) {
echo $tag['hello'];
}
}
string | $name | The tag name |
bool | $throwOnAbstract |
array | An array of tags |
Returns all tags the defined services use.
array | An array of tags |
Returns all tags not queried by findTaggedServiceIds.
string[] | An array of tags |
ExpressionFunctionProviderInterface | $provider |
ExpressionFunctionProviderInterface[] |
Returns a ChildDefinition that will be used for autoconfiguring the interface/class.
string | $interface | The class or interface to match |
ChildDefinition |
Returns an array of ChildDefinition[] keyed by interface.
ChildDefinition[] |
Resolves env parameter placeholders in a string or an array.
mixed | $value | The value to resolve |
string|true|null | $format | A sprintf() format returning the replacement for each env var name or null to resolve back to the original "%env(VAR)%" format or true to resolve to the actual values of the referenced env vars |
array | $usedEnvs | &$usedEnvs Env vars found while resolving are added to this array |
mixed | The value with env parameters resolved if a string or an array is passed |
Get statistics about env usage.
int[] | The number of time each env vars has been resolved |
CompilerPassInterface | $pass | |
string | $message |
Returns the Service Conditionals.
mixed | $value | An array of conditionals to return |
array | An array of Service conditionals |
Returns the initialized conditionals.
mixed | $value | An array of conditionals to return |
array | An array of uninitialized conditionals |
Computes a reasonably unique hash of a value.
mixed | $value | A serializable value |
string |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationContainerBuilder.html