Dependencies
Components\Component\Task\Dependencies:: Declare and receive dependencies
Copyright 2011-2019 Horde LLC (http://www.horde.org/)
See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Tags
Table of Contents
- $_deps : mixed
- askDependencies() : array<string|int, string>
- Ask for dependencies.
- getDependency() : object|null
- Retrieve a dependency
- setDependencies() : void
- Receive dependencies
Properties
$_deps
protected
mixed
$_deps
= []
Methods
askDependencies()
Ask for dependencies.
public
askDependencies() : array<string|int, string>
Declares which helpers or other utilities the task wants to have
The request format is an associative array. The key will be reused by the answer from outside, the value is a string identifying the base class or interface of the dependency.
As long as the injector knows how to provide the dependencies, there is no need for individual factories or annotations per task.
Dependencies unfulfilled should be returned as null values for the keys.
The task should decide itself if this is fatal or optional
Return values
array<string|int, string> —The dictionary of dependencies.
getDependency()
Retrieve a dependency
public
getDependency(string $key) : object|null
It must have been registered by askDependencies and the calling code should provide it or null
Parameters
- $key : string
-
The dependency to get.
Return values
object|null —The dependency or null
setDependencies()
Receive dependencies
public
setDependencies(array<string|int, mixed> $dependencies) : void
The format contains the same keys ad askDependencies, but the values are instances of the requested types or null if unfulfilled.
Parameters
- $dependencies : array<string|int, mixed>
-
The provided dependencies.