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

static Resolver
singleton()

Singleton function.

array|callable
get(string|array $id)

Convert a callback expression to a valid PHP callback.

mixed
call(string|callable $id, array $args)

Invoke a callback expression.

Details

at line 43
static Resolver singleton()

Singleton function.

Return Value

Resolver

at line 60
array|callable get(string|array $id)

Convert a callback expression to a valid PHP callback.

Parameters

string|array $id A callback expression; any of the following.

Return Value

array|callable A PHP callback. Do not serialize (b/c it may include an object).

Exceptions

RuntimeException

at line 117
mixed call(string|callable $id, array $args)

Invoke a callback expression.

Parameters

string|callable $id
array $args Ordered parameters. To call-by-reference, set an array-parameter by reference.

Return Value

mixed