Methods |
public
|
unload(): void
Close the object's underlying resources
Close the object's underlying resources
Overriden by
Implements
|
#
|
public
static
|
hasGlobalContainer(): bool
Check if the global container is set
Check if the global container is set
Implements
|
#
|
public
static
|
getGlobalContainer(): ContainerInterface
Get the global container, creating it if necessary
Get the global container, creating it if necessary
Implements
|
#
|
public
static
|
setGlobalContainer(?ContainerInterface $container): void
Set or unset the global container
Set or unset the global container
Dispatches {@see BeforeGlobalContainerSetEvent} if the global container
will change.
Implements
|
#
|
public
|
get(string $id, array $args = []): object
Finds an entry of the container by its identifier and returns it.
Finds an entry of the container by its identifier and returns it.
Parameters
$id |
Identifier of the entry to look for.
|
Returns
Implements
|
#
|
public
|
getAs(string $id, string $service, array $args = []): object
Resolve a partially-resolved service from the container
Resolve a partially-resolved service from the container
$id is resolved normally, but $service is passed to
{@see ServiceAwareInterface::setService()} instead of $id .
Implements
|
#
|
public
|
getClass(string $id): string
Resolve a service from the container without returning an instance
Resolve a service from the container without returning an instance
Returns the class name of the object {@see get()} would return.
Implements
|
#
|
public
|
has(string $id): bool
Returns true if the container can return an entry for the given identifier.
Returns false otherwise.
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
$id |
Identifier of the entry to look for.
|
Implements
|
#
|
public
|
hasSingleton(string $id): bool
Check if a shared service or instance is bound to the container
Check if a shared service or instance is bound to the container
Implements
|
#
|
public
|
hasInstance(string $id): bool
Check if a service resolves to a shared instance
Check if a service resolves to a shared instance
Implements
|
#
|
public
|
inContextOf(string $id): ContainerInterface
Apply contextual bindings to a copy of the container
Apply contextual bindings to a copy of the container
Implements
|
#
|
public
|
bind(string $id, $class = null): ContainerInterface
Bind a service to the container
Bind a service to the container
Subsequent requests for $id resolve to an instance of $class , or
$id if $class is null .
If $class is a closure, it is called every time $id is resolved.
Implements
|
#
|
public
|
bindIf(string $id, $class = null): ContainerInterface
Bind a service to the container if it isn't already bound
Bind a service to the container if it isn't already bound
Implements
|
#
|
public
|
singleton(string $id, $class = null): ContainerInterface
Bind a shared service to the container
Bind a shared service to the container
Subsequent requests for $id resolve to the shared instance created when
$id is first requested.
Implements
|
#
|
public
|
singletonIf(string $id, $class = null): ContainerInterface
Bind a shared service to the container if it isn't already bound
Bind a shared service to the container if it isn't already bound
Implements
|
#
|
public
|
hasProvider(string $provider): bool
Check if a service provider is registered with the container
Check if a service provider is registered with the container
Implements
|
#
|
public
|
provider(
string $provider,
?array $services = null,
array $excludeServices = [],
int $providerLifetime = Container::LIFETIME_INHERIT,
): ContainerInterface
Register a service provider with the container, optionally specifying
which of its services to bind or ignore
Register a service provider with the container, optionally specifying
which of its services to bind or ignore
For performance reasons, classes bound to the container with
{@see bind()} or {@see singleton()} are not loaded until they are
resolved. Classes registered with {@see provider()} are loaded
immediately to check for {@see HasServices}, {@see SingletonInterface}
and other implementations.
Parameters
$services |
Services of $provider to bind to
the container, or null to bind every service returned by
{@see HasServices::getServices()} (if implemented).
|
$excludeServices |
Services of $provider to exclude
from binding.
|
Implements
|
#
|
public
|
addContextualBinding($context, string $id, $class = null): ContainerInterface
Add a contextual binding to the container
Add a contextual binding to the container
Subsequent requests for $id from the given contexts resolve to:
- the return value of
$class (if it is a closure)
- an instance of
$class (if it is a string)
$class itself (if it is an object), or
- an instance of
$id (if $class is null )
If $id starts with '$' , it is matched with constructor parameters of
the same name, and $class cannot be null .
Implements
|
#
|
public
|
instance(string $id, object $instance): ContainerInterface
Bind a shared instance to the container
Bind a shared instance to the container
Implements
|
#
|
public
|
providers(array $providers, int $providerLifetime = Container::LIFETIME_INHERIT): ContainerInterface
Register an array that maps services (usually interfaces) to service
providers (classes that extend or implement theā¦
Register an array that maps services (usually interfaces) to service
providers (classes that extend or implement the mapped service)
Multiple services may be mapped to the same service provider. Unmapped
providers are mapped to themselves.
Implements
|
#
|
public
|
getProviders(): array
Get a list of service providers registered with the container
Get a list of service providers registered with the container
Implements
|
#
|
public
|
removeInstance(string $id): ContainerInterface
Remove a shared instance from the container
Remove a shared instance from the container
Implements
|
#
|