Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
DI\CompiledContainer Class Reference
Inheritance diagram for DI\CompiledContainer:
DI\Container Psr\Container\ContainerInterface DI\FactoryInterface Invoker\InvokerInterface

Public Member Functions

 call ($callable, array $parameters=[])
 Call the given function using the given parameters.
 
 debugEntry (string $name)
 Get entry debug information.
 
 get (string $id)
 Returns an entry of the container by its name.
 
 getKnownEntryNames ()
 Get defined container entries.
 
 has (string $id)
 Returns true if the container can return an entry for the given identifier.
 
 injectOn (object $instance)
 Inject all dependencies on an existing instance.
 
 make (string $name, array $parameters=[])
 Build an entry of the container by its name.
 
 set (string $name, mixed $value)
 Define an object or a value in the container.
 

Static Public Member Functions

static create (array $definitions)
 

Protected Member Functions

 resolveFactory ($callable, $entryName, array $extraParameters=[])
 Invoke the given callable.
 
 setDefinition (string $name, Definition $definition)
 

Protected Attributes

ContainerInterface $delegateContainer
 Container that wraps this container.
 
array $entriesBeingResolved = []
 Array of entries being resolved.
 
ProxyFactory $proxyFactory
 
array $resolvedEntries = []
 Map of entries that are already resolved.
 
array const METHOD_MAPPING = []
 This const is overridden in child classes (compiled containers).
 

Member Function Documentation

◆ call()

DI\Container::call ( $callable,
array $parameters = [] )
inherited

Call the given function using the given parameters.

Missing parameters will be resolved from the container.

Parameters
callable | array | string$callableFunction to call.
array$parametersParameters 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\get().
Return values
mixedResult of the function.

Implements Invoker\InvokerInterface.

◆ debugEntry()

DI\Container::debugEntry ( string $name)
inherited

Get entry debug information.

Parameters
string$nameEntry name
Exceptions
InvalidDefinition
NotFoundException

◆ get()

DI\CompiledContainer::get ( string $id)

Returns an entry of the container by its name.

@template T

Parameters
string|class-string<T>$id Entry name or a class name.
Return values
mixed|T
Exceptions
DependencyExceptionError while resolving the entry.
NotFoundExceptionNo entry found for the given name.

Reimplemented from DI\Container.

◆ getKnownEntryNames()

DI\Container::getKnownEntryNames ( )
inherited

Get defined container entries.

Return values
string[]

◆ has()

DI\CompiledContainer::has ( string $id)

Returns true if the container can return an entry for the given identifier.

Returns false otherwise.

has($id) returning true does not mean that get($id) will not throw an exception. It does however mean that get($id) will not throw a NotFoundExceptionInterface.

Parameters
string$idIdentifier of the entry to look for.
Return values
bool

Reimplemented from DI\Container.

◆ injectOn()

DI\Container::injectOn ( object $instance)
inherited

Inject all dependencies on an existing instance.

@template T

Parameters
object | T$instanceObject to perform injection upon
Return values
object|T\$instanceReturns the same instance
Exceptions
InvalidArgumentException
DependencyExceptionError while injecting dependencies

◆ make()

DI\Container::make ( string $name,
array $parameters = [] )
inherited

Build an entry of the container by its name.

This method behave like get() except resolves the entry again every 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.

@template T

Parameters
string|class-string<T>$name Entry name or a class name.
array$parametersOptional 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.
Return values
mixed|T
Exceptions
InvalidArgumentExceptionThe name parameter must be of type string.
DependencyExceptionError while resolving the entry.
NotFoundExceptionNo entry found for the given name.

Implements DI\FactoryInterface.

◆ set()

DI\Container::set ( string $name,
mixed $value )
inherited

Define an object or a value in the container.

Parameters
string$nameEntry name
mixed | DefinitionHelper$valueValue, use definition helpers to define objects

◆ setDefinition()

DI\CompiledContainer::setDefinition ( string $name,
Definition $definition )
protected

Reimplemented from DI\Container.

Member Data Documentation

◆ $delegateContainer

ContainerInterface DI\Container::$delegateContainer
protectedinherited

Container that wraps this container.

If none, points to $this.

◆ $entriesBeingResolved

array DI\Container::$entriesBeingResolved = []
protectedinherited

Array of entries being resolved.

Used to avoid circular dependencies and infinite loops.


The documentation for this class was generated from the following file: