Commit d3c5919d authored by catch's avatar catch
Browse files

Issue #2045919 by drupalrv: Replace all module_implements() deprecated function calls.

parent 29c09eff
......@@ -1579,7 +1579,7 @@ function watchdog($type, $message, array $variables = NULL, $severity = WATCHDOG
}
// Call the logging hooks to log/process the message
foreach (module_implements('watchdog') as $module) {
foreach (Drupal::moduleHandler()->getImplementations('watchdog') as $module) {
$function = $module . '_watchdog';
$function($log_entry);
}
......
......@@ -3247,7 +3247,7 @@ function drupal_cron_run() {
}
// Iterate through the modules calling their cron handlers (if any):
foreach (module_implements('cron') as $module) {
foreach (Drupal::moduleHandler()->getImplementations('cron') as $module) {
// Do not let an exception thrown by one module disturb another.
try {
module_invoke($module, 'cron');
......@@ -3637,7 +3637,7 @@ function drupal_render_page($page) {
}
// Modules can add elements to $page as needed in hook_page_build().
foreach (module_implements('page_build') as $module) {
foreach (Drupal::moduleHandler()->getImplementations('page_build') as $module) {
$function = $module . '_page_build';
$function($page);
}
......
......@@ -1746,7 +1746,7 @@ function menu_get_active_help() {
$arg = drupal_help_arg(arg(NULL));
foreach (module_implements('help') as $module) {
foreach (Drupal::moduleHandler()->getImplementations('help') as $module) {
$function = $module . '_help';
// Lookup help for this path.
if ($help = $function($router_path, $arg)) {
......@@ -2753,7 +2753,7 @@ function menu_router_build($save = FALSE) {
// We need to manually call each module so that we can know which module
// a given item came from.
$callbacks = array();
foreach (module_implements('menu') as $module) {
foreach (Drupal::moduleHandler()->getImplementations('menu') as $module) {
$router_items = call_user_func($module . '_menu');
if (isset($router_items) && is_array($router_items)) {
foreach (array_keys($router_items) as $path) {
......
......@@ -81,7 +81,7 @@ function drupal_get_complete_schema($rebuild = FALSE) {
require_once __DIR__ . '/common.inc';
// Invoke hook_schema for all modules.
foreach (module_implements('schema') as $module) {
foreach (Drupal::moduleHandler()->getImplementations('schema') as $module) {
// Cast the result of hook_schema() to an array, as a NULL return value
// would cause array_merge() to set the $schema variable to NULL as well.
// That would break modules which use $schema further down the line.
......
......@@ -609,7 +609,7 @@ function _theme_build_registry($theme, $base_theme, $theme_engine) {
$cache = $cached->data;
}
else {
foreach (module_implements('theme') as $module) {
foreach (Drupal::moduleHandler()->getImplementations('theme') as $module) {
_theme_process_registry($cache, $module, 'module', $module, drupal_get_path('module', $module));
}
// Only cache this registry if all modules are loaded.
......
......@@ -293,7 +293,7 @@ protected function buildQuery($ids, $revision_id = FALSE) {
*/
protected function attachLoad(&$queried_entities, $revision_id = FALSE) {
// Call hook_entity_load().
foreach (module_implements('entity_load') as $module) {
foreach (\Drupal::moduleHandler()->getImplementations('entity_load') as $module) {
$function = $module . '_entity_load';
$function($queried_entities, $this->entityType);
}
......@@ -301,7 +301,7 @@ protected function attachLoad(&$queried_entities, $revision_id = FALSE) {
// always the queried entities, followed by additional arguments set in
// $this->hookLoadArguments.
$args = array_merge(array($queried_entities), $this->hookLoadArguments);
foreach (module_implements($this->entityType . '_load') as $module) {
foreach (\Drupal::moduleHandler()->getImplementations($this->entityType . '_load') as $module) {
call_user_func_array($module . '_' . $this->entityType . '_load', $args);
}
}
......
......@@ -346,7 +346,7 @@ protected function attachLoad(&$queried_entities, $load_revision = FALSE) {
}
// Call hook_entity_load().
foreach (module_implements('entity_load') as $module) {
foreach (\Drupal::moduleHandler()->getImplementations('entity_load') as $module) {
$function = $module . '_entity_load';
$function($queried_entities, $this->entityType);
}
......@@ -354,7 +354,7 @@ protected function attachLoad(&$queried_entities, $load_revision = FALSE) {
// always the queried entities, followed by additional arguments set in
// $this->hookLoadArguments.
$args = array_merge(array($queried_entities), $this->hookLoadArguments);
foreach (module_implements($this->entityType . '_load') as $module) {
foreach (\Drupal::moduleHandler()->getImplementations($this->entityType . '_load') as $module) {
call_user_func_array($module . '_' . $this->entityType . '_load', $args);
}
}
......
......@@ -45,7 +45,7 @@ public function getDefinition($plugin_id) {
*/
public function getDefinitions() {
$definitions = array();
foreach (module_implements($this->hook) as $module) {
foreach (\Drupal::moduleHandler()->getImplementations($this->hook) as $module) {
$function = $module . '_' . $this->hook;
foreach ($function() as $plugin_id => $definition) {
$definition['module'] = $module;
......
......@@ -54,7 +54,7 @@ public function getDefinition($plugin_id) {
*/
public function getDefinitions() {
$definitions = $this->decorated->getDefinitions();
foreach (module_implements($this->hook) as $module) {
foreach (\Drupal::moduleHandler()->getImplementations($this->hook) as $module) {
$function = $module . '_' . $this->hook;
$function($definitions);
}
......
......@@ -290,7 +290,7 @@ function _block_get_renderable_region($list = array()) {
// chances of having unwanted output get in the cache and later be served
// to other users. We therefore exclude user 1 from block caching.
$not_cacheable = $GLOBALS['user']->id() == 1 ||
count(module_implements('node_grants')) ||
count(Drupal::moduleHandler()->getImplementations('node_grants')) ||
!\Drupal::request()->isMethodSafe();
foreach ($list as $key => $block) {
......
......@@ -73,7 +73,7 @@ public function entityQueryAlter(SelectInterface $query) {
// Passing the query to node_query_node_access_alter() is sadly
// insufficient for nodes.
// @see SelectionEntityTypeNode::entityQueryAlter()
if (!user_access('bypass node access') && !count(module_implements('node_grants'))) {
if (!user_access('bypass node access') && !count(\Drupal::moduleHandler()->getImplementations('node_grants'))) {
$query->condition($node_alias . '.status', 1);
}
}
......
......@@ -519,7 +519,7 @@ function field_attach_form(EntityInterface $entity, &$form, &$form_state, $langc
// Let other modules make changes to the form.
// Avoid module_invoke_all() to let parameters be taken by reference.
foreach (module_implements('field_attach_form') as $module) {
foreach (Drupal::moduleHandler()->getImplementations('field_attach_form') as $module) {
$function = $module . '_field_attach_form';
$function($entity, $form, $form_state, $langcode);
}
......@@ -621,7 +621,7 @@ function field_attach_load($entity_type, $entities, $age = FIELD_LOAD_CURRENT, $
// Invoke hook_field_storage_pre_load(): let any module load field
// data before the storage engine, accumulating along the way.
$skip_fields = array();
foreach (module_implements('field_storage_pre_load') as $module) {
foreach (Drupal::moduleHandler()->getImplementations('field_storage_pre_load') as $module) {
$function = $module . '_field_storage_pre_load';
$function($entity_type, $queried_entities, $age, $skip_fields, $hook_options);
}
......@@ -824,7 +824,7 @@ function field_attach_extract_form_values(EntityInterface $entity, $form, &$form
// Let other modules act on submitting the entity.
// Avoid module_invoke_all() to let $form_state be taken by reference.
foreach (module_implements('field_attach_extract_form_values') as $module) {
foreach (Drupal::moduleHandler()->getImplementations('field_attach_extract_form_values') as $module) {
$function = $module . 'field_attach_extract_form_values';
$function($entity, $form, $form_state);
}
......@@ -853,7 +853,7 @@ function field_attach_insert(EntityInterface $entity) {
// Let any module insert field data before the storage engine, accumulating
// saved fields along the way.
$skip_fields = array();
foreach (module_implements('field_storage_pre_insert') as $module) {
foreach (Drupal::moduleHandler()->getImplementations('field_storage_pre_insert') as $module) {
$function = $module . '_field_storage_pre_insert';
$function($entity, $skip_fields);
}
......@@ -894,7 +894,7 @@ function field_attach_update(EntityInterface $entity) {
// Let any module update field data before the storage engine, accumulating
// saved fields along the way.
$skip_fields = array();
foreach (module_implements('field_storage_pre_update') as $module) {
foreach (Drupal::moduleHandler()->getImplementations('field_storage_pre_update') as $module) {
$function = $module . '_field_storage_pre_update';
$function($entity, $skip_fields);
}
......
......@@ -323,7 +323,7 @@ function field_purge_data(EntityInterface $entity, $field, $instance) {
module_invoke($field['storage']['module'], 'field_storage_purge', $entity, $field, $instance);
// Let other modules act on purging the data.
foreach (module_implements('field_attach_purge') as $module) {
foreach (Drupal::moduleHandler()->getImplementations('field_attach_purge') as $module) {
$function = $module . '_field_attach_purge';
$function($entity, $field, $instance);
}
......
......@@ -83,7 +83,7 @@ function _field_info_collate_types() {
);
// Populate storage types.
foreach (module_implements('field_storage_info') as $module) {
foreach (Drupal::moduleHandler()->getImplementations('field_storage_info') as $module) {
$storage_types = (array) module_invoke($module, 'field_storage_info');
foreach ($storage_types as $name => $storage_info) {
// Provide defaults.
......
......@@ -145,7 +145,7 @@ function field_help($path, $arg) {
// order by displayed module name (module names are not translated).
$items = array();
$info = system_get_info('module');
$modules = array_merge(module_implements('field_info'), module_implements('field_widget_info'));
$modules = array_merge(Drupal::moduleHandler()->getImplementations('field_info'), Drupal::moduleHandler()->getImplementations('field_widget_info'));
$modules = array_unique($modules);
sort($modules);
foreach ($modules as $module) {
......@@ -873,7 +873,7 @@ function field_access($op, FieldInterface $field, $entity_type, $entity = NULL,
$account = $user;
}
foreach (module_implements('field_access') as $module) {
foreach (Drupal::moduleHandler()->getImplementations('field_access') as $module) {
$function = $module . '_field_access';
$access = $function($op, $field, $entity_type, $entity, $account);
if ($access === FALSE) {
......
......@@ -56,7 +56,8 @@ public function getDefinition($plugin_id) {
public function getDefinitions() {
$definitions = $this->decorated->getDefinitions();
// We cannot use HookDiscovery, since it uses module_implements(), which
// We cannot use HookDiscovery, since it uses
// Drupal::moduleHandler()->getImplementations(), which
// throws exceptions during upgrades.
foreach (array_keys($this->moduleHandler->getModuleList()) as $module) {
$function = $module . '_field_info';
......
......@@ -660,7 +660,7 @@ function file_file_download($uri, $field_type = 'file') {
// Invoke hook and collect grants/denies for download access.
// Default to FALSE and let entities overrule this ruling.
$grants = array('system' => FALSE);
foreach (module_implements('file_download_access') as $module) {
foreach (Drupal::moduleHandler()->getImplementations('file_download_access') as $module) {
$grants = array_merge($grants, array($module => module_invoke($module, 'file_download_access', $field, $entity, $file)));
}
// Allow other modules to alter the returned grants/denies.
......
......@@ -16,7 +16,7 @@ function help_menu() {
'weight' => 9,
);
$modules = module_implements('help');
$modules = Drupal::moduleHandler()->getImplementations('help');
ksort($modules);
foreach ($modules as $module) {
$items['admin/help/' . $module] = array(
......
......@@ -108,7 +108,7 @@ protected function verifyHelp($response = 200) {
protected function getModuleList() {
$modules = array();
$module_data = system_rebuild_module_data();
foreach (module_implements('help') as $module) {
foreach (\Drupal::moduleHandler()->getImplementations('help') as $module) {
$modules[$module] = $module_data[$module]->info['name'];
}
return $modules;
......
......@@ -349,7 +349,7 @@ public function validate(array $form, array &$form_state) {
// Invoke hook_node_validate() for validation needed by modules.
// Can't use module_invoke_all(), because $form_state must
// be receivable by reference.
foreach (module_implements('node_validate') as $module) {
foreach (\Drupal::moduleHandler()->getImplementations('node_validate') as $module) {
$function = $module . '_node_validate';
$function($node, $form, $form_state);
}
......@@ -376,7 +376,7 @@ public function submit(array $form, array &$form_state) {
}
node_submit($node);
foreach (module_implements('node_submit') as $module) {
foreach (\Drupal::moduleHandler()->getImplementations('node_submit') as $module) {
$function = $module . '_node_submit';
$function($node, $form, $form_state);
}
......
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