Commit 447adf98 authored by webchick's avatar webchick

Issue #1899514 by sun, Dave Reid: Fixed ModuleHandlerInterface::getHookInfo...

Issue #1899514 by sun, Dave Reid: Fixed ModuleHandlerInterface::getHookInfo should not be protected.
parent da63e126
......@@ -63,6 +63,30 @@ public function getBootstrapModules() {
return $this->bootstrapModules;
}
/**
* Overrides \Drupal\Core\Extension\ModuleHandler::getHookInfo().
*/
public function getHookInfo() {
// When this function is indirectly invoked from bootstrap_invoke_all() prior
// to all modules being loaded, we do not want to cache an incomplete
// hook_hookInfo() result, so instead return an empty array. This requires
// bootstrap hook implementations to reside in the .module file, which is
// optimal for performance anyway.
if (!$this->loaded) {
return array();
}
if (!isset($this->hookInfo)) {
if ($cache = $this->bootstrapCache->get('hook_info')) {
$this->hookInfo = $cache->data;
}
else {
$this->hookInfo = parent::getHookInfo();
$this->bootstrapCache->set('hook_info', $this->hookInfo);
}
}
return $this->hookInfo;
}
/**
* Implements \Drupal\Core\Extension\ModuleHandlerInterface::resetImplementations().
*/
......@@ -128,30 +152,6 @@ protected function getImplementationInfo($hook) {
return $this->implementations[$hook];
}
/**
* Overrides \Drupal\Core\Extension\ModuleHandler::getHookInfo().
*/
protected function getHookInfo() {
// When this function is indirectly invoked from bootstrap_invoke_all() prior
// to all modules being loaded, we do not want to cache an incomplete
// hook_hookInfo() result, so instead return an empty array. This requires
// bootstrap hook implementations to reside in the .module file, which is
// optimal for performance anyway.
if (!$this->loaded) {
return array();
}
if (!isset($this->hookInfo)) {
if ($cache = $this->bootstrapCache->get('hook_info')) {
$this->hookInfo = $cache->data;
}
else {
$this->hookInfo = parent::getHookInfo();
$this->bootstrapCache->set('hook_info', $this->hookInfo);
}
}
return $this->hookInfo;
}
/**
* Retrieves hook implementation info from the cache.
*/
......
......@@ -221,6 +221,28 @@ public function loadInclude($module, $type, $name = NULL) {
return FALSE;
}
/**
* Implements \Drupal\Core\Extension\ModuleHandlerInterface::getHookInfo().
*/
public function getHookInfo() {
if (isset($this->hookInfo)) {
return $this->hookInfo;
}
$this->hookInfo = array();
// We can't use $this->invokeAll() here or it would cause an infinite
// loop.
foreach ($this->moduleList as $module => $filename) {
$function = $module . '_hook_info';
if (function_exists($function)) {
$result = $function();
if (isset($result) && is_array($result)) {
$this->hookInfo = NestedArray::mergeDeep($this->hookInfo, $result);
}
}
}
return $this->hookInfo;
}
/**
* Implements \Drupal\Core\Extension\ModuleHandlerInterface::getImplementations().
*/
......@@ -437,35 +459,6 @@ protected function getImplementationInfo($hook) {
return $this->implementations[$hook];
}
/**
* Retrieves a list of hooks that are declared through hook_hook_info().
*
* @return
* An associative array whose keys are hook names and whose values are an
* associative array containing a group name. The structure of the array
* is the same as the return value of hook_hook_info().
*
* @see hook_hook_info()
*/
protected function getHookInfo() {
if ($this->hookInfo) {
return $this->hookInfo;
}
$this->hookInfo = array();
// We can't use $this->invokeAll() here or it would cause an infinite
// loop.
foreach ($this->moduleList as $module => $filename) {
$function = $module . '_hook_info';
if (function_exists($function)) {
$result = $function();
if (isset($result) && is_array($result)) {
$this->hookInfo = NestedArray::mergeDeep($this->hookInfo, $result);
}
}
}
return $this->hookInfo;
}
/**
* Parses a dependency for comparison by drupal_check_incompatibility().
*
......
......@@ -140,6 +140,18 @@ public function loadAllIncludes($type, $name = NULL);
*/
public function loadInclude($module, $type, $name = NULL);
/**
* Retrieves a list of hooks that are declared through hook_hook_info().
*
* @return array
* An associative array whose keys are hook names and whose values are an
* associative array containing a group name. The structure of the array
* is the same as the return value of hook_hook_info().
*
* @see hook_hook_info()
*/
public function getHookInfo();
/**
* Determines which modules are implementing a hook.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment