extends |
ContainerInterface, Chainable, Instantiable, Unloadable |
---|
A service container with contextual bindings
If a service resolves to a new instance of a class that implements
ContainerAwareInterface
, the container is passed to its
{@see ContainerAwareInterface::setContainer()} method.
Then, if the resolved instance implements {@see ServiceAwareInterface}, its {@see ServiceAwareInterface::setService()} method is called.
A service provider registered via {@see provider()} or {@see providers()} may also implement any combination of the following interfaces:
{@see SingletonInterface} is ignored if a lifetime other than {@see ServiceLifetime::INHERIT} is given when the service provider is registered.
Methods | ||
---|---|---|
public
|
__construct()
|
# |
public
static
|
hasGlobalContainer(): bool
|
# |
public
static
|
getGlobalContainer(): ContainerInterface
|
# |
public
static
|
setGlobalContainer(?ContainerInterface $container): void
|
# |
public
|
inContextOf(class-string $id): static
|
# |
public
|
get<T>(class-string<T> $id, mixed[] $args = []): T&object
|
# |
public
|
getAs<T, TService>(class-string<T> $id, class-string<TService> $service, mixed[] $args = []): T&TService&object
|
# |
public
|
getName<T>(class-string<T> $id): class-string<T>
|
# |
public
|
has(class-string $id): bool
|
# |
public
|
hasSingleton(class-string $id): bool
|
# |
public
|
hasInstance(class-string $id): bool
|
# |
public
|
hasProvider(class-string $id): bool
|
# |
public
|
bind<TService, T is TService>(class-string<TService> $id, class-string<T>|null $class = null, mixed[] $args = []): $this
|
# |
public
|
bindIf<TService, T is TService>(
class-string<TService> $id,
class-string<T>|null $class = null,
mixed[] $args = [],
): $this
|
# |
public
|
singleton<TService, T is TService>(
class-string<TService> $id,
class-string<T>|null $class = null,
mixed[] $args = [],
): $this
|
# |
public
|
singletonIf<TService, T is TService>(
class-string<TService> $id,
class-string<T>|null $class = null,
mixed[] $args = [],
): $this
|
# |
public
|
instance<TService, T is TService>(class-string<TService> $id, T&object $instance): $this
|
# |
public
|
addContextualBinding<TValue>(
class-string[]|class-string $context,
class-string<TValue>|string $dependency,
(callable(ContainerInterface): TValue)|class-string<TValue>|TValue $value,
): $this
|
# |
public
|
provider(
class-string $id,
class-string[]|null $services = null,
class-string[] $exceptServices = [],
ServiceLifetime::* $lifetime = ServiceLifetime::INHERIT,
): $this
|
# |
public
|
providers(array<class-string, class-string> $serviceMap, ServiceLifetime::* $lifetime = ServiceLifetime::INHERIT): $this
|
# |
public
|
getProviders(): array<class-string>
|
# |
public
|
unbind(class-string $id): $this
|
# |
public
|
removeInstance(class-string $id): $this
|
# |
Methods inherited from Salient\Contract\Core\Chainable |
---|
apply(), if(), withEach() |
Methods inherited from Salient\Contract\Core\Unloadable |
---|
unload() |