You are here

function apdqc_after_entity_info_alter in Asynchronous Prefetch Database Query Cache 7

Implements hook_entity_info_alter().

File

./apdqc.module, line 530
Asynchronous Prefetch Database Query Cache module.

Code

function apdqc_after_entity_info_alter(&$entity_info) {
  $entity_controller_class_info =& drupal_static('apdqc_entity_info_alter');
  foreach ($entity_info as $type => $info) {
    if (isset($info['fieldable']) && !empty($entity_controller_class_info[$type]) && $entity_controller_class_info[$type] === $info['controller class']) {
      $classes = class_implements($info['controller class']);

      // Only use prefetch shim if class only implements
      // DrupalEntityControllerInterface.
      if (count($classes) == 1 && isset($classes['DrupalEntityControllerInterface'])) {

        // Controller class is not being overwritten; put in prefetch class.
        $entity_info[$type]['original controller class'] = $info['controller class'];
        $entity_info[$type]['controller class'] = 'ApdqcPrefetchDrupalDefaultEntityController';
      }
    }
  }
}