You are here

function ModuleImplements::moduleImplements in X Autoload 7.5

Parameters

string $hook:

bool $sort:

Return value

array

See also

module_implements()

File

tests/src/VirtualDrupal/ModuleImplements.php, line 85

Class

ModuleImplements

Namespace

Drupal\xautoload\Tests\VirtualDrupal

Code

function moduleImplements($hook, $sort = FALSE) {

  // Use the advanced drupal_static() pattern, since this is called very often.
  if (!isset($this->drupalStaticFast)) {
    $this->drupalStaticFast['implementations'] =& $this->drupalStatic
      ->get('module_implements');
  }
  $implementations =& $this->drupalStaticFast['implementations'];

  // Fetch implementations from cache.
  if (empty($implementations)) {
    $cache = $this->cache
      ->cacheGet('module_implements', 'cache_bootstrap');
    if (FALSE === $cache) {
      $implementations = array();
    }
    else {
      $implementations = $cache->data;
    }
  }
  if (!isset($implementations[$hook])) {
    $implementations[$hook] = $this
      ->discoverImplementations($hook, $sort);
  }
  else {

    // @todo Change this when https://drupal.org/node/2263365 has landed in Drupal core.
    $this
      ->filterImplementations($implementations[$hook], $hook);
  }
  return array_keys($implementations[$hook]);
}