Constructor for the DI Container
Container
__construct
([
Container $parent =
null])
-
Container
$parent: Parent for hierarchical containers.
Create an alias for a given key for easy access.
-
string
$alias: The alias name
-
string
$key: The key to alias
Build an object of class $key;
mixed
buildObject
(string $key, [boolean $shared = false])
-
string
$key: The class name to build.
-
boolean
$shared: True to create a shared resource.
Convenience method for building a shared object.
object Instance
buildSharedObject
(string $key)
-
string
$key: The class name to build.
Create a child Container with a new property scope that that has the ability to access the parent scope when resolving.
Extend a defined service Closure by wrapping the existing one with a new Closure. This works very similar to a decorator pattern. Note that this only works on service Closures that have been defined in the current Provider, not parent providers.
void
extend
(string $key, Closure \$callable, \Closure $callable)
-
string
$key: The unique identifier for the Closure or property.
-
\Closure
$callable: A Closure to wrap the original service Closure.
-
Closure
\$callable
Method to retrieve the results of running the $callback for the specified $key;
mixed
get
(string $key, [boolean $forceNew = false])
-
string
$key: Name of the dataStore key to get.
-
boolean
$forceNew: True to force creation and return of a new instance.
Build an array of constructor parameters.
array
getMethodArgs
(ReflectionMethod \$method, \ReflectionMethod $method)
-
\ReflectionMethod
$method: Method for which to build the argument array.
-
ReflectionMethod
\$method
Method to force the container to return a new instance of the results of the callback for requested $key.
mixed
getNewInstance
(string $key)
-
string
$key: Name of the dataStore key to get.
Get the raw data assigned to a key.
mixed
getRaw
(string $key)
-
string
$key: The key for which to get the stored item.
Convenience method for creating protected keys.
\Joomla\DI\Container
protect
(string $key, callable $callback, [bool $shared = false])
-
string
$key: Name of dataStore key to set.
-
callable
$callback: Callable function to run when requesting the specified $key.
-
bool
$shared: True to create and store a shared instance.
Register a service provider to the container.
Search the aliases property for a matching alias key.
string
resolveAlias
(string $key)
-
string
$key: The key to search for.
Method to set the key and callback to the dataStore array.
\Joomla\DI\Container
set
(string $key, mixed $value, [boolean $shared = false], [boolean $protected = false])
-
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.
-
boolean
$protected: True to protect this item from being overwritten. Useful for services.
Convenience method for creating shared keys.
\Joomla\DI\Container
share
(string $key, callable $callback, [bool $protected = false])
-
string
$key: Name of dataStore key to set.
-
callable
$callback: Callable function to run when requesting the specified $key.
-
bool
$protected: True to create and store a shared instance.