Most of the executors support custom operators (hint: if they implement
ExtendableExecutor
, they do).
The ArrayExecutor
filters existing collections so the operators are simple
callables evaluated on the fly.
You can register a new operator directly in the constructor or by calling the
registerOperators
method. Both ways are strictly equivalent.
$executor = new ArrayExecutor([
'length' => 'strlen',
]);
$executor->registerOperators([
'logged' => function($user) {
return return $user::CONNECTED === $user->getStatus();
},
]);
This executor is a bit different than the last one as it does not filter an existing collection but transforms a rule in a query. Because of this, the callables must return the DQL equivalent of the operator being defined.
$executor = new DoctrineQueryBuilderExecutor([
'like' => function ($a, $b) {
return sprintf('%s LIKE %s', $a, $b);
},
]);
Return to the index to explore the other possibilities of the library