Skip to content

Options

Michal Štefaňák edited this page Aug 12, 2021 · 12 revisions

Options keys are available as constants in Deepr class. You can find additional information in official runtime.

Key Description Value type Default value
OPTION_CONTEXT A context that will be passed as the last parameter to all invoked methods.
null value is ignored and it's not passed as argument.
mixed null
OPTION_IGNORE_KEYS A key or an array of keys to be ignored when executing the query. A key can be specified as a string or a RegExp. array []
OPTION_ACCEPT_KEYS A key or an array of keys to be accepted regardless if they are ignored using the ignoreKeys option. A key can be specified as a string or a RegExp. array []
OPTION_AUTHORIZER A function that is called for each key to authorize any operation.
The function receives current node, key and an operation which can be either 'get' for reading an attribute or 'call' for invoking a method.
The function must return true to authorize an operation. If false is returned, the evaluation of the query stops immediately, and an error is thrown. more info
callable (mixed currentNode, string key, string operation) null

Example

$result = $deepr->invokeQuery($root, $input, [
    $deepr::OPTION_IGNORE_KEYS => ["/^_/"],
    $deepr::OPTION_ACCEPT_KEYS => ['_id']
]);

To see more examples check phpunit tests.

Clone this wiki locally