Resolver
class Resolver
The resolver takes a string expression and returns an object or callable.
The following patterns will resolve to objects: - 'obj://objectName' - An object from Civi\Core\Container - 'ClassName' - An instance of ClassName (with default constructor). If you need more control over construction, then register with the container.
The following patterns will resolve to callables: - 'function_name' - A function(callable). - 'ClassName::methodName" - A static method of a class. - 'call://objectName/method' - A method on an object from Civi\Core\Container. - 'api3://EntityName/action' - A method call on an API. (Performance note: Requires full setup/teardown of API subsystem.) - 'api3://EntityName/action?first=@1&second=@2' - Call an API method, mapping the first & second args to named parameters. (Performance note: Requires parsing/interpolating arguments). - 'global://Variable/Key2/Key3?getter' - A dummy which looks up a global variable. - 'global://Variable/Key2/Key3?setter' - A dummy which updates a global variable. - '0' or '1' - A dummy which returns the constant '0' or '1'.
Note: To differentiate classes and functions, there is a hard requirement that class names begin with an uppercase letter.
Note: If you are working in a context which requires a callable, it is legitimate to use an object notation ("obj://objectName" or "ClassName") if the object supports __invoke().
Properties
static protected | $_singleton |
Methods
Convert a callback expression to a valid PHP callback.
Invoke a callback expression.
Details
at line 43
static Resolver
singleton()
Singleton function.
at line 60
array|callable
get(string|array $id)
Convert a callback expression to a valid PHP callback.
at line 117
mixed
call(string|callable $id, array $args)
Invoke a callback expression.