Inherits Container, ContainerInterface, FactoryInterface, and InvokerInterface.
|
| | __construct (DefinitionSource $definitionSource, ProxyFactory $proxyFactory, ContainerInterface $wrapperContainer=null) |
| |
| | get ($name) |
| |
| | make ($name, array $parameters=[]) |
| |
| | has ($name) |
| |
| | injectOn ($instance) |
| |
| | call ($callable, array $parameters=[]) |
| |
| | set ($name, $value) |
| |
Container pro pristup k predkum
upravena trida z DI
◆ __construct()
| __construct |
( |
DefinitionSource |
$definitionSource, |
|
|
ProxyFactory |
$proxyFactory, |
|
|
ContainerInterface |
$wrapperContainer = null |
|
) |
| |
Use the ContainerBuilder to ease constructing the Container.
- See also
- ContainerBuilder
- Parameters
-
| DefinitionSource | $definitionSource | |
| ProxyFactory | $proxyFactory | |
| ContainerInterface | $wrapperContainer | If the container is wrapped by another container. |
◆ call()
| call |
( |
|
$callable, |
|
|
array |
$parameters = [] |
|
) |
| |
Call the given function using the given parameters.
Missing parameters will be resolved from the container.
- Parameters
-
| callable | $callable | Function to call. |
| array | $parameters | Parameters to use. Can be indexed by the parameter names or not indexed (same order as the parameters). The array can also contain DI definitions, e.g. DI(). |
- Returns
- mixed Result of the function.
◆ get()
Returns an entry of the container by its name.
- Parameters
-
| string | $name | Entry name or a class name. |
- Exceptions
-
| InvalidArgumentException | The name parameter must be of type string. |
| DependencyException | Error while resolving the entry. |
| NotFoundException | No entry found for the given name. |
- Returns
- mixed
◆ has()
Test if the container can provide something for the given name.
- Parameters
-
| string | $name | Entry name or a class name. |
- Exceptions
-
| InvalidArgumentException | The name parameter must be of type string. |
- Returns
- bool
◆ injectOn()
Inject all dependencies on an existing instance
- Parameters
-
| object | $instance | Object to perform injection upon |
- Exceptions
-
| InvalidArgumentException | |
| DependencyException | Error while injecting dependencies |
- Returns
- object $instance Returns the same instance
◆ make()
| make |
( |
|
$name, |
|
|
array |
$parameters = [] |
|
) |
| |
Build an entry of the container by its name.
This method behave like get() except it forces the scope to "prototype", which means the definition of the entry will be re-evaluated each time. For example, if the entry is a class, then a new instance will be created each time.
This method makes the container behave like a factory.
- Parameters
-
| string | $name | Entry name or a class name. |
| array | $parameters | Optional parameters to use to build the entry. Use this to force specific parameters to specific values. Parameters not defined in this array will be resolved using the container. |
- Exceptions
-
| InvalidArgumentException | The name parameter must be of type string. |
| DependencyException | Error while resolving the entry. |
| NotFoundException | No entry found for the given name. |
- Returns
- mixed
◆ set()
Define an object or a value in the container.
- Parameters
-
| string | $name | Entry name |
| mixed | DefinitionHelper | $value | Value, use definition helpers to define objects |
The documentation for this class was generated from the following file: