Elgg  Version 5.1
Clause.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Database\Clauses;
4 
8 
14 abstract class Clause {
15 
16  use Loggable;
17 
26  abstract public function prepare(QueryBuilder $qb, $table_alias = null);
27 
35  protected function isCallable($callback) {
36  return _elgg_services()->handlers->isCallable($callback);
37  }
38 
48  protected function call($callback, QueryBuilder $qb, $table_alias = null) {
49  $service = _elgg_services()->handlers;
50 
51  $callable = $service->resolveCallable($callback);
52  if (!is_callable($callable)) {
53  $description = static::class . ' (QueryBuilder, table_alias)';
54  $this->getLogger()->warning("Handler for {$description} is not callable: " . $service->describeCallable($callback));
55 
56  return false;
57  }
58 
59  return call_user_func($callable, $qb, $table_alias);
60  }
61 
72  protected function callJoin($callback, QueryBuilder $qb, $joined_alias, $table_alias = null) {
73  $service = _elgg_services()->handlers;
74 
75  $callable = $service->resolveCallable($callback);
76  if (!is_callable($callable)) {
77  $description = static::class . ' (QueryBuilder, joined_alias, table_alias)';
78  $this->getLogger()->warning("Handler for {$description} is not callable: " . $service->describeCallable($callback));
79 
80  return false;
81  }
82 
83  return call_user_func($callable, $qb, $joined_alias, $table_alias);
84  }
85 }
call($callback, QueryBuilder $qb, $table_alias=null)
Call the expression for the clause.
Definition: Clause.php:48
Interface that allows resolving statements and/or extending query builder.
Definition: Clause.php:14
Database abstraction query builder.
prepare(QueryBuilder $qb, $table_alias=null)
Build an expression and/or apply it to an instance of query builder.
trait Loggable
Enables adding a logger.
Definition: Loggable.php:14
$description
Definition: record.php:15
getLogger()
Returns logger.
Definition: Loggable.php:37
isCallable($callback)
Check if a clause expression is callable.
Definition: Clause.php:35
callJoin($callback, QueryBuilder $qb, $joined_alias, $table_alias=null)
Call the expression for a join clause.
Definition: Clause.php:72
_elgg_services()
Get the global service provider.
Definition: elgglib.php:346
$qb
Definition: queue.php:11