You are here

private function ModuleImplements::discoverImplementations in X Autoload 7.5

Parameters

string $hook:

bool $sort:

Return value

array

1 call to ModuleImplements::discoverImplementations()
ModuleImplements::moduleImplements in tests/src/VirtualDrupal/ModuleImplements.php

File

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

Class

ModuleImplements

Namespace

Drupal\xautoload\Tests\VirtualDrupal

Code

private function discoverImplementations($hook, $sort) {

  # StaticCallLog::addCall();

  // The hook is not cached, so ensure that whether or not it has
  // implementations, that the cache is updated at the end of the request.
  $this->writeCache = TRUE;
  $hook_info = $this
    ->moduleHookInfo();
  $implementations = array();
  $list = $this->moduleList
    ->moduleList(FALSE, FALSE, $sort);
  if ('modules_enabled' === $hook) {

    # HackyLog::logx($list);
  }
  foreach ($list as $module) {
    $include_file = isset($hook_info[$hook]['group']) && module_load_include('inc', $module, $module . '.' . $hook_info[$hook]['group']);

    // Since module_hook() may needlessly try to load the include file again,
    // function_exists() is used directly here.
    if (function_exists($module . '_' . $hook)) {
      $implementations[$module] = $include_file ? $hook_info[$hook]['group'] : FALSE;
    }
  }

  // Allow modules to change the weight of specific implementations but avoid
  // an infinite loop.
  if ($hook != 'module_implements_alter') {
    $this->hookSystem
      ->drupalAlter('module_implements', $implementations, $hook);
  }
  return $implementations;
}