Container
extends
ContainerInterface
in
Describes the interface of a container that exposes methods to read its entries.
Table of Contents
- afterResolving() : void
- Register a new after resolving callback.
- alias() : void
- Alias a type to a different name.
- bind() : void
- Register a binding with the container.
- bindIf() : void
- Register a binding if it hasn't already been registered.
- bound() : bool
- Determine if the given abstract type has been bound.
- call() : mixed
- Call the given Closure / class@method and inject its dependencies.
- extend() : void
- "Extend" an abstract type in the container.
- factory() : Closure
- Get a closure to resolve the given type from the container.
- get() : mixed
- Finds an entry of the container by its identifier and returns it.
- has() : bool
- Returns true if the container can return an entry for the given identifier.
- instance() : mixed
- Register an existing instance as shared in the container.
- make() : mixed
- Resolve the given type from the container.
- resolved() : bool
- Determine if the given abstract type has been resolved.
- resolving() : void
- Register a new resolving callback.
- singleton() : void
- Register a shared binding in the container.
- tag() : void
- Assign a set of tags to a given binding.
- tagged() : array<string|int, mixed>
- Resolve all of the bindings for a given tag.
- when() : ContextualBindingBuilder
- Define a contextual binding.
Methods
afterResolving()
Register a new after resolving callback.
public
afterResolving(Closure|string $abstract[, Closure|null $callback = null ]) : void
Parameters
- $abstract : Closure|string
- $callback : Closure|null = null
Return values
void —alias()
Alias a type to a different name.
public
alias(string $abstract, string $alias) : void
Parameters
- $abstract : string
- $alias : string
Return values
void —bind()
Register a binding with the container.
public
bind(string $abstract[, Closure|string|null $concrete = null ][, bool $shared = false ]) : void
Parameters
- $abstract : string
- $concrete : Closure|string|null = null
- $shared : bool = false
Return values
void —bindIf()
Register a binding if it hasn't already been registered.
public
bindIf(string $abstract[, Closure|string|null $concrete = null ][, bool $shared = false ]) : void
Parameters
- $abstract : string
- $concrete : Closure|string|null = null
- $shared : bool = false
Return values
void —bound()
Determine if the given abstract type has been bound.
public
bound(string $abstract) : bool
Parameters
- $abstract : string
Return values
bool —call()
Call the given Closure / class@method and inject its dependencies.
public
call(callable|string $callback[, array<string|int, mixed> $parameters = [] ][, string|null $defaultMethod = null ]) : mixed
Parameters
- $callback : callable|string
- $parameters : array<string|int, mixed> = []
- $defaultMethod : string|null = null
Return values
mixed —extend()
"Extend" an abstract type in the container.
public
extend(string $abstract, Closure $closure) : void
Parameters
- $abstract : string
- $closure : Closure
Tags
Return values
void —factory()
Get a closure to resolve the given type from the container.
public
factory(string $abstract) : Closure
Parameters
- $abstract : string
Return values
Closure —get()
Finds an entry of the container by its identifier and returns it.
public
get(string $id) : mixed
Parameters
- $id : string
-
Identifier of the entry to look for.
Tags
Return values
mixed —Entry.
has()
Returns true if the container can return an entry for the given identifier.
public
has(string $id) : bool
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
- $id : string
-
Identifier of the entry to look for.
Return values
bool —instance()
Register an existing instance as shared in the container.
public
instance(string $abstract, mixed $instance) : mixed
Parameters
- $abstract : string
- $instance : mixed
Return values
mixed —make()
Resolve the given type from the container.
public
make(string $abstract[, array<string|int, mixed> $parameters = [] ]) : mixed
Parameters
- $abstract : string
- $parameters : array<string|int, mixed> = []
Return values
mixed —resolved()
Determine if the given abstract type has been resolved.
public
resolved(string $abstract) : bool
Parameters
- $abstract : string
Return values
bool —resolving()
Register a new resolving callback.
public
resolving(Closure|string $abstract[, Closure|null $callback = null ]) : void
Parameters
- $abstract : Closure|string
- $callback : Closure|null = null
Return values
void —singleton()
Register a shared binding in the container.
public
singleton(string $abstract[, Closure|string|null $concrete = null ]) : void
Parameters
- $abstract : string
- $concrete : Closure|string|null = null
Return values
void —tag()
Assign a set of tags to a given binding.
public
tag(array<string|int, mixed>|string $abstracts, array<string|int, mixed>|mixed ...$tags) : void
Parameters
- $abstracts : array<string|int, mixed>|string
- $tags : array<string|int, mixed>|mixed
Return values
void —tagged()
Resolve all of the bindings for a given tag.
public
tagged(string $tag) : array<string|int, mixed>
Parameters
- $tag : string
Return values
array<string|int, mixed> —when()
Define a contextual binding.
public
when(string $concrete) : ContextualBindingBuilder
Parameters
- $concrete : string