db
Container Class Reference

Inherits Container, ContainerInterface, FactoryInterface, and InvokerInterface.

Public Member Functions

 __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)
 

Detailed Description

Container pro pristup k predkum

upravena trida z DI

Constructor & Destructor Documentation

◆ __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$wrapperContainerIf the container is wrapped by another container.

Member Function Documentation

◆ call()

call (   $callable,
array  $parameters = [] 
)

Call the given function using the given parameters.

Missing parameters will be resolved from the container.

Parameters
callable$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().
Returns
mixed Result of the function.

◆ get()

get (   $name)

Returns an entry of the container by its name.

Parameters
string$nameEntry name or a class name.
Exceptions
InvalidArgumentExceptionThe name parameter must be of type string.
DependencyExceptionError while resolving the entry.
NotFoundExceptionNo entry found for the given name.
Returns
mixed

◆ has()

has (   $name)

Test if the container can provide something for the given name.

Parameters
string$nameEntry name or a class name.
Exceptions
InvalidArgumentExceptionThe name parameter must be of type string.
Returns
bool

◆ injectOn()

injectOn (   $instance)

Inject all dependencies on an existing instance

Parameters
object$instanceObject to perform injection upon
Exceptions
InvalidArgumentException
DependencyExceptionError 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$nameEntry 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.
Exceptions
InvalidArgumentExceptionThe name parameter must be of type string.
DependencyExceptionError while resolving the entry.
NotFoundExceptionNo entry found for the given name.
Returns
mixed

◆ set()

set (   $name,
  $value 
)

Define an object or a value in the container.

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

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