Documentation

Resolver
in package

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().

Table of Contents

Properties

$_singleton  : mixed

Methods

call()  : mixed
Invoke a callback expression.
get()  : array<string|int, mixed>|callable
Convert a callback expression to a valid PHP callback.
singleton()  : Resolver
Singleton function.

Properties

$_singleton

protected static mixed $_singleton

Methods

call()

Invoke a callback expression.

public call(string|callable $id, array<string|int, mixed> $args) : mixed
Parameters
$id : string|callable
$args : array<string|int, mixed>

Ordered parameters. To call-by-reference, set an array-parameter by reference.

get()

Convert a callback expression to a valid PHP callback.

public get(string|array<string|int, mixed> $id) : array<string|int, mixed>|callable
Parameters
$id : string|array<string|int, mixed>

A callback expression; any of the following.

Tags
throws
RuntimeException
Return values
array<string|int, mixed>|callable

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


        
On this page

Search results