Symfony\Component\DependencyInjection\Container
Container is a dependency injection container.
It gives access to object instances (services).
Services and parameters are simple key/pair stores.
Parameter and service keys are case insensitive.
A service id can contain lowercased letters, digits, underscores, and dots.
Underscores are used to separate words, and dots to group services
under namespaces:
<ul>
<li>request</li>
<li>mysql_session_storage</li>
<li>symfony.mysql_session_storage</li>
</ul>
A service can also be defined by creating a method named
getXXXService(), where XXX is the camelized version of the id:
<ul>
<li>request -> getRequestService()</li>
<li>mysql_session_storage -> getMysqlSessionStorageService()</li>
<li>symfony.mysql_session_storage -> getSymfony_MysqlSessionStorageService()</li>
</ul>
The container can have three possible behaviors when a service does not exist:
* EXCEPTION_ON_INVALID_REFERENCE: Throws an exception (the default)
* NULL_ON_INVALID_REFERENCE: Returns null
* IGNORE_ON_INVALID_REFERENCE: Ignores the wrapping command asking for the reference
(for instance, ignore a setter if the service does not exist)
- Author: Fabien Potencier <fabien@symfony.com>
Synopsis
- // members
- protected ParameterBagInterface $parameterBag;
- protected $services;
- protected $methodMap;
- protected $aliases;
- protected $scopes;
- protected $scopeChildren;
- protected $scopedServices;
- protected $scopeStacks;
- protected array $loading;
- // methods
- public void __construct()
- public void compile()
- public Boolean isFrozen()
- public ParameterBagInterface getParameterBag()
- public mixed getParameter()
- public Boolean hasParameter()
- public void setParameter()
- public void set()
- public Boolean has()
- public get()
- public Boolean initialized()
- public array getServiceIds()
- public void enterScope()
- public void leaveScope()
- public void addScope()
- public Boolean hasScope()
- public Boolean isScopeActive()
- public static string camelize()
- public static string underscore()
Hierarchy
Extended by
Implements
Members
protected
- $aliases
- $loading
- $methodMap
- $parameterBag — Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface
- $scopeChildren
- $scopeStacks
- $scopedServices
- $scopes
- $services
Methods
public
- __construct() — Constructor.
- addScope() — Adds a scope to the container.
- camelize() — Camelizes a string.
- compile() — Compiles the container.
- enterScope() — This is called when you enter a scope
- get() — Gets a service.
- getParameter() — Gets a parameter.
- getParameterBag() — Gets the service container parameter bag.
- getServiceIds() — Gets all service ids.
- has() — Returns true if the given service is defined.
- hasParameter() — Checks if a parameter exists.
- hasScope() — Returns whether this container has a certain scope
- initialized() — Returns true if the given service has actually been initialized
- isFrozen() — Returns true if the container parameter bag are frozen.
- isScopeActive() — Returns whether this scope is currently active
- leaveScope() — This is called to leave the current scope, and move back to the parent scope.
- set() — Sets a service.
- setParameter() — Sets a parameter.
- underscore() — A string to underscore.