|
| __construct (?ContainerInterface $parent=null) |
|
| get ($resourceName) |
|
| has ($resourceName) |
|
| exists ($key) |
|
| alias ($alias, $key) |
|
| isShared (string $resourceName) |
|
| isProtected (string $resourceName) |
|
| tag ($tag, array $keys) |
|
| getTagged ($tag) |
|
| buildObject ($resourceName, $shared=false) |
|
| buildSharedObject ($resourceName) |
|
| createChild () |
|
| extend ($resourceName, callable $callable) |
|
| set ($key, $value, $shared=false, $protected=false) |
|
| protect ($key, $value, $shared=false) |
|
| share ($key, $value, $protected=false) |
|
| getResource (string $key, bool $bail=false) |
|
| getNewInstance ($key) |
|
| registerServiceProvider (ServiceProviderInterface $provider) |
|
| getKeys () |
|
| get (string $id) |
|
| has (string $id) |
|
The Container class.
- Depuis
- 1.0
◆ __construct()
◆ alias()
Create an alias for a given key for easy access.
- Paramètres
-
string | $alias | The alias name |
string | $key | The key to alias |
- Renvoie
- $this
- Depuis
- 1.0
Références $key, et $this.
◆ buildObject()
buildObject |
( |
|
$resourceName, |
|
|
|
$shared = false |
|
) |
| |
Build an object of the requested class
Creates an instance of the class specified by $resourceName with all dependencies injected. If the dependencies cannot be completely resolved, a DependencyResolutionException is thrown.
- Paramètres
-
string | $resourceName | The class name to build. |
boolean | $shared | True to create a shared resource. |
- Renvoie
- object|false Instance of class specified by $resourceName with all dependencies injected. Returns an object if the class exists and false otherwise
- Depuis
- 1.0
- Exceptions
-
DependencyResolutionException | if the object could not be built (due to missing information) |
Références $key, Container\getMethodArgs(), Container\has(), null, et Container\resolveAlias().
Référencé par Container\buildSharedObject(), et Container\getMethodArgs().
◆ buildSharedObject()
buildSharedObject |
( |
|
$resourceName | ) |
|
Convenience method for building a shared object.
- Paramètres
-
string | $resourceName | The class name to build. |
- Renvoie
- object|false Instance of class specified by $resourceName with all dependencies injected. Returns an object if the class exists and false otherwise
- Depuis
- 1.0
Références Container\buildObject().
◆ createChild()
Create a child Container with a new property scope that has the ability to access the parent scope when resolving.
- Renvoie
- Container A new container with the current as a parent
- Depuis
- 1.0
Références $this.
◆ exists()
◆ extend()
extend |
( |
|
$resourceName, |
|
|
callable |
$callable |
|
) |
| |
Extend a defined service Closure by wrapping the existing one with a new callable function.
This works very similar to a decorator pattern. Note that this only works on service Closures that have been defined in the current container, not parent containers.
- Paramètres
-
string | $resourceName | The unique identifier for the Closure or property. |
callable | $callable | A callable to wrap the original service Closure. |
- Renvoie
- void
- Depuis
- 1.0
- Exceptions
-
Références $c, $key, Container\getResource(), et Container\resolveAlias().
◆ get()
◆ getKeys()
Retrieve the keys for services assigned to this container.
- Renvoie
- array
- Depuis
- 1.5.0
◆ getMethodArgs()
getMethodArgs |
( |
\ReflectionMethod |
$method | ) |
|
|
private |
◆ getNewInstance()
Method to force the container to return a new instance of the results of the callback for requested $key.
- Paramètres
-
string | $key | Name of the resources key to get. |
- Renvoie
- mixed Results of running the callback for the specified key.
- Depuis
- 1.0
Références $key, Container\getResource(), et Container\resolveAlias().
◆ getResource()
getResource |
( |
string |
$key, |
|
|
bool |
$bail = false |
|
) |
| |
◆ getTagged()
Fetch all services registered to the given tag.
- Paramètres
-
- Renvoie
- array The resolved services for the given tag
- Depuis
- 1.5.0
◆ has()
◆ hasFlag()
hasFlag |
( |
string |
$resourceName, |
|
|
string |
$method, |
|
|
bool |
$default = true |
|
) |
| |
|
private |
◆ isProtected()
isProtected |
( |
string |
$resourceName | ) |
|
Check whether a resource is protected
- Paramètres
-
string | $resourceName | Name of the resource to check. |
- Renvoie
- boolean
- Depuis
- 2.0.0
Références Container\hasFlag().
Référencé par Container\set().
◆ isShared()
isShared |
( |
string |
$resourceName | ) |
|
Check whether a resource is shared
- Paramètres
-
string | $resourceName | Name of the resource to check. |
- Renvoie
- boolean
- Depuis
- 2.0.0
Références Container\hasFlag().
◆ protect()
protect |
( |
|
$key, |
|
|
|
$value, |
|
|
|
$shared = false |
|
) |
| |
Shortcut method for creating protected keys.
- Paramètres
-
string | $key | Name of dataStore key to set. |
mixed | $value | Callable function to run or string to retrive when requesting the specified $key. |
boolean | $shared | True to create and store a shared instance. |
- Renvoie
- $this
- Depuis
- 1.0
Références $key, et $value.
◆ registerServiceProvider()
◆ resolveAlias()
resolveAlias |
( |
|
$resourceName | ) |
|
|
protected |
◆ set()
set |
( |
|
$key, |
|
|
|
$value, |
|
|
|
$shared = false , |
|
|
|
$protected = false |
|
) |
| |
Set a resource to the container. If the value is null the resource is removed.
- Paramètres
-
string | $key | Name of resources key to set. |
mixed | $value | Callable function to run or string to retrive when requesting the specified $key. |
boolean | $shared | True to create and store a shared instance. |
boolean | $protected | True to protect this item from being overwritten. Useful for services. |
- Renvoie
- $this
- Depuis
- 1.0
- Exceptions
-
ProtectedKeyException | Thrown if the provided key is already set and is protected. |
Références $key, $mode, $this, $value, Container\has(), Container\isProtected(), ContainerResource\NO_PROTECT, ContainerResource\NO_SHARE, null, ContainerResource\PROTECT, Container\resolveAlias(), et ContainerResource\SHARE.
◆ share()
share |
( |
|
$key, |
|
|
|
$value, |
|
|
|
$protected = false |
|
) |
| |
Shortcut method for creating shared keys.
- Paramètres
-
string | $key | Name of dataStore key to set. |
mixed | $value | Callable function to run or string to retrive when requesting the specified $key. |
boolean | $protected | True to protect this item from being overwritten. Useful for services. |
- Renvoie
- $this
- Depuis
- 1.0
Références $key, et $value.
◆ tag()
tag |
( |
|
$tag, |
|
|
array |
$keys |
|
) |
| |
Assign a tag to services.
- Paramètres
-
string | $tag | The tag name |
array | $keys | The service keys to tag |
- Renvoie
- $this
- Depuis
- 1.5.0
Références $key, $this, et Container\resolveAlias().
◆ $aliases
◆ $parent
◆ $resources
◆ $tags
La documentation de cette classe a été générée à partir du fichier suivant :