You are here

public function SelectExtender::__call in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Database/Query/SelectExtender.php \Drupal\Core\Database\Query\SelectExtender::__call()

Magic override for undefined methods.

If one extender extends another extender, then methods in the inner extender will not be exposed on the outer extender. That's because we cannot know in advance what those methods will be, so we cannot provide wrapping implementations as we do above. Instead, we use this slower catch-all method to handle any additional methods.

File

core/lib/Drupal/Core/Database/Query/SelectExtender.php, line 504
Contains \Drupal\Core\Database\Query\SelectExtender.

Class

SelectExtender
The base extender class for Select queries.

Namespace

Drupal\Core\Database\Query

Code

public function __call($method, $args) {
  $return = call_user_func_array(array(
    $this->query,
    $method,
  ), $args);

  // Some methods will return the called object as part of a fluent interface.
  // Others will return some useful value.  If it's a value, then the caller
  // probably wants that value.  If it's the called object, then we instead
  // return this object.  That way we don't "lose" an extender layer when
  // chaining methods together.
  if ($return instanceof SelectInterface) {
    return $this;
  }
  else {
    return $return;
  }
}