public function DbHelper::__call in MongoDB 8
File
- drivers/lib/Drupal/Driver/Database/mongodb/DbHelper.php, line 28
- Contains \Drupal\Driver\Database\mongodb\TestQuery.
Class
- DbHelper
Namespace
Drupal\Driver\Database\mongodb
Code
public function __call($name, $args) {
if (in_array($name, [
'query',
'select',
'update',
'insert',
'merge',
'delete',
'truncate',
])) {
$this->calls = [];
$this->hash = [];
}
$this->calls[$name][] = $args;
if ($name == 'query') {
$args = $args[0];
}
if ($name == 'condition') {
unset($args[1]);
}
if (!isset($this->calls['select'])) {
if ($name == 'fields' || $name == 'values') {
$keys = array_keys($args[0]);
if ($keys !== range(0, count($keys) - 1)) {
$args = $keys;
}
elseif ($name == 'values') {
$args = [];
}
}
}
$this->hash[$name][] = $args;
$method = 'do' . substr(hash('sha256', serialize($this->hash)), 0, 8);
if (method_exists($this, $method)) {
return call_user_func([
$this,
$method,
]);
}
return $this;
}