DiContainer
in package
A wrapper around the DI\Container functionality that will allow static usage of container methods.
Table of Contents
Properties
Methods
- getClass() : T
- Retrieve the managed instance of $className, or construct a new instance with all dependencies.
- getContainer() : ResettableContainer|ResettableCompiledContainer
- Return the raw dependency injection Container instance for more robust container management operations.
- initialize() : void
- Create a new DI\Container instance.
- initialized() : bool
- Check if a managed instance of $className has been created.
- makeClass() : T
- Construct a fresh instance of $className. Dependencies will be retrieved from the container if they are already managed, and created themselves if they are not.
- __construct() : mixed
- buildContainer() : ResettableContainer|ResettableCompiledContainer
- getDefinitions() : array<string, mixed>
Properties
$container read-only
private
ResettableContainer|ResettableCompiledContainer
$container
$instance
private
static DiContainer
$instance
Methods
getClass()
Retrieve the managed instance of $className, or construct a new instance with all dependencies.
public
static getClass(T> $className) : T
Parameters
- $className : T>
-
The name of the class to retrieve from the container.
Tags
Return values
TgetContainer()
Return the raw dependency injection Container instance for more robust container management operations.
public
static getContainer() : ResettableContainer|ResettableCompiledContainer
Return values
ResettableContainer|ResettableCompiledContainerinitialize()
Create a new DI\Container instance.
public
static initialize(bool $enableCompilation) : void
This needs to be done once during a bootstrapping script, like bootstrap.php
Parameters
- $enableCompilation : bool
initialized()
Check if a managed instance of $className has been created.
public
static initialized(string $className) : bool
If the container itself has not been initialized yet, will always return false.
Parameters
- $className : string
Return values
boolmakeClass()
Construct a fresh instance of $className. Dependencies will be retrieved from the container if they are already managed, and created themselves if they are not.
public
static makeClass(T> $className) : T
Parameters
- $className : T>
-
The name of the class to construct.
Tags
Return values
T__construct()
private
__construct(bool $enableCompilation) : mixed
Parameters
- $enableCompilation : bool
buildContainer()
private
buildContainer(bool $enableCompilation) : ResettableContainer|ResettableCompiledContainer
Parameters
- $enableCompilation : bool
Return values
ResettableContainer|ResettableCompiledContainergetDefinitions()
private
getDefinitions() : array<string, mixed>