public function ApdqcPrefetchDrupalDefaultEntityController::__call in Asynchronous Prefetch Database Query Cache 7
Magic method; forward all calls to the original base class.
On load calls prefetch the field data.
Parameters
string $name: Name of the method called.
array $arguments: Array of parameters passed to the method.
File
- ./
apdqc.module, line 582 - Asynchronous Prefetch Database Query Cache module.
Class
- ApdqcPrefetchDrupalDefaultEntityController
- Passthrough DrupalDefaultEntityController class for prefetching cache ids.
Code
public function __call($name, array $arguments) {
if ($name == 'load' && function_exists('apdqc_run_prefetch_array') && function_exists('apdqc_escape_string')) {
if (apdqc_get_bin_class_name('cache_field') === 'APDQCache') {
// Use the advanced drupal_static() pattern, since this is called very
// often.
static $drupal_static_fast;
if (!isset($drupal_static_fast)) {
$drupal_static_fast['cache_field'] =& drupal_static('apdqc_cache_prefetch_ids');
}
$table_keys_cache_prefetch = array();
if (!empty($arguments[0])) {
foreach ($arguments[0] as $id) {
if (is_string($id) || is_numeric($id)) {
$string = apdqc_escape_string('field:' . $this->originalEntityType . ':' . $id);
if (!isset($drupal_static_fast['cache_field'][$string])) {
$drupal_static_fast['cache_field'][$string] = TRUE;
$table_keys_cache_prefetch['cache_field'][] = $string;
}
}
}
}
// Prefetch cache.
if (!empty($table_keys_cache_prefetch)) {
apdqc_run_prefetch_array($table_keys_cache_prefetch);
}
}
}
if ($name == 'load' && !empty($arguments[0]) && is_array($arguments[0]) && count($arguments[0]) == 1 && variable_get('apdqc_entity_load_skip_null', APDQC_ENTITY_LOAD_SKIP_NULL)) {
$test = reset($arguments[0]);
if (empty($test) && is_null($test)) {
return array();
}
}
$return = call_user_func_array(array(
$this->originalBaseClass,
$name,
), $arguments);
return $return;
}