Commit e33ddd1b authored by alexpott's avatar alexpott
Browse files

Issue #2045923 by drupalrv, tim.plunkett: Replace all module_invoke_all()...

Issue #2045923 by drupalrv, tim.plunkett: Replace all module_invoke_all() deprecated function calls in procedural code.
parent 89f62691
......@@ -3229,7 +3229,7 @@ function drupal_cron_run() {
$return = FALSE;
// Grab the defined cron queues.
$queues = module_invoke_all('queue_info');
$queues = Drupal::moduleHandler()->invokeAll('queue_info');
drupal_alter('queue_info', $queues);
// Try to acquire cron lock.
......@@ -4275,7 +4275,7 @@ function element_info($type) {
$cache = &$drupal_static_fast['cache'];
if (!isset($cache)) {
$cache = module_invoke_all('element_info');
$cache = Drupal::moduleHandler()->invokeAll('element_info');
foreach ($cache as $element_type => $info) {
$cache[$element_type]['#type'] = $element_type;
}
......@@ -4828,7 +4828,7 @@ function archiver_get_archiver($file) {
function drupal_get_updaters() {
$updaters = &drupal_static(__FUNCTION__);
if (!isset($updaters)) {
$updaters = module_invoke_all('updater_info');
$updaters = Drupal::moduleHandler()->invokeAll('updater_info');
drupal_alter('updater_info', $updaters);
uasort($updaters, 'drupal_sort_weight');
}
......@@ -4848,7 +4848,7 @@ function drupal_get_updaters() {
function drupal_get_filetransfer_info() {
$info = &drupal_static(__FUNCTION__);
if (!isset($info)) {
$info = module_invoke_all('filetransfer_info');
$info = Drupal::moduleHandler()->invokeAll('filetransfer_info');
drupal_alter('filetransfer_info', $info);
uasort($info, 'drupal_sort_weight');
}
......
......@@ -65,7 +65,7 @@ function entity_get_bundles($entity_type = NULL) {
$bundles = $cache->data;
}
else {
$bundles = module_invoke_all('entity_bundle_info');
$bundles = Drupal::moduleHandler()->invokeAll('entity_bundle_info');
// If no bundles are provided, use the entity type name and label.
foreach (entity_get_info() as $type => $entity_info) {
if (!isset($bundles[$type])) {
......@@ -102,7 +102,7 @@ function entity_get_bundles($entity_type = NULL) {
*/
function entity_invoke_bundle_hook($hook, $entity_type, $bundle, $bundle_new = NULL) {
entity_info_cache_clear();
module_invoke_all('entity_bundle_' . $hook, $entity_type, $bundle, $bundle_new);
Drupal::moduleHandler()->invokeAll('entity_bundle_' . $hook, array($entity_type, $bundle, $bundle_new));
}
/**
......
......@@ -189,7 +189,7 @@ function file_get_stream_wrappers($filter = STREAM_WRAPPERS_ALL) {
$wrappers_storage = &drupal_static(__FUNCTION__);
if (!isset($wrappers_storage)) {
$wrappers = module_invoke_all('stream_wrappers');
$wrappers = Drupal::moduleHandler()->invokeAll('stream_wrappers');
foreach ($wrappers as $scheme => $info) {
// Add defaults.
$wrappers[$scheme] += array('type' => STREAM_WRAPPERS_NORMAL);
......
......@@ -820,7 +820,7 @@ function drupal_retrieve_form($form_id, &$form_state) {
// So, we call the hook if $forms isn't yet populated, OR if it doesn't
// yet have an entry for the requested form_id.
if (!isset($forms) || !isset($forms[$form_id])) {
$forms = module_invoke_all('forms', $form_id, $args);
$forms = Drupal::moduleHandler()->invokeAll('forms', array($form_id, $args));
}
$form_definition = $forms[$form_id];
if (isset($form_definition['callback arguments'])) {
......
......@@ -161,7 +161,7 @@ function language_types_info() {
$language_types = &drupal_static(__FUNCTION__);
if (!isset($language_types)) {
$language_types = module_invoke_all('language_types_info');
$language_types = Drupal::moduleHandler()->invokeAll('language_types_info');
// Let other modules alter the list of language types.
drupal_alter('language_types_info', $language_types);
}
......@@ -413,7 +413,7 @@ function language_negotiation_info() {
if (!isset($negotiation_info)) {
// Collect all the module-defined language negotiation methods.
$negotiation_info = module_invoke_all('language_negotiation_info');
$negotiation_info = Drupal::moduleHandler()->invokeAll('language_negotiation_info');
$languages = language_list();
$selected_language = $languages[language_from_selected($languages)];
$description = 'Language based on a selected language. ';
......
......@@ -1776,7 +1776,7 @@ function menu_get_custom_theme($initialize = FALSE) {
// First allow modules to dynamically set a custom theme for the current
// page. Since we can only have one, the last module to return a valid
// theme takes precedence.
$custom_themes = array_filter(module_invoke_all('custom_theme'), 'drupal_theme_access');
$custom_themes = array_filter(Drupal::moduleHandler()->invokeAll('custom_theme'), 'drupal_theme_access');
if (!empty($custom_themes)) {
$custom_theme = array_pop($custom_themes);
}
......
......@@ -158,7 +158,7 @@ function path_is_admin($path) {
function path_get_admin_paths() {
$patterns = &drupal_static(__FUNCTION__);
if (!isset($patterns)) {
$paths = module_invoke_all('admin_paths');
$paths = Drupal::moduleHandler()->invokeAll('admin_paths');
drupal_alter('admin_paths', $paths);
// Combine all admin paths into one array, and likewise for non-admin paths,
// for easier handling.
......
......@@ -1489,7 +1489,7 @@ function theme_enable($theme_list) {
drupal_theme_rebuild();
// Invoke hook_themes_enabled() after the themes have been enabled.
module_invoke_all('themes_enabled', $theme_list);
Drupal::moduleHandler()->invokeAll('themes_enabled', array($theme_list));
}
/**
......@@ -1525,7 +1525,7 @@ function theme_disable($theme_list) {
drupal_theme_rebuild();
// Invoke hook_themes_disabled after the themes have been disabled.
module_invoke_all('themes_disabled', $theme_list);
Drupal::moduleHandler()->invokeAll('themes_disabled', array($theme_list));
}
/**
......
......@@ -1247,22 +1247,22 @@ function update_already_performed($module, $number) {
/**
* Invokes hook_update_dependencies() in all installed modules.
*
* This function is similar to module_invoke_all(), with the main difference
* that it does not require that a module be enabled to invoke its hook, only
* that it be installed. This allows the update system to properly perform
* updates even on modules that are currently disabled.
* This function is similar to \Drupal::moduleHandler()->invokeAll(), with the
* main difference that it does not require that a module be enabled to invoke
* its hook, only that it be installed. This allows the update system to
* properly perform updates even on modules that are currently disabled.
*
* @return
* An array of return values obtained by merging the results of the
* hook_update_dependencies() implementations in all installed modules.
*
* @see module_invoke_all()
* @see \Drupal::moduleHandler()->invokeAll()
* @see hook_update_dependencies()
*/
function update_retrieve_dependencies() {
$return = array();
// Get a list of installed modules, arranged so that we invoke their hooks in
// the same order that module_invoke_all() does.
// the same order that \Drupal::moduleHandler()->invokeAll() does.
foreach (Drupal::keyValue('system.schema')->getAll() as $module => $schema) {
if ($schema == SCHEMA_UNINSTALLED) {
// Nothing to upgrade.
......
......@@ -518,7 +518,8 @@ function field_attach_form(EntityInterface $entity, &$form, &$form_state, $langc
$form['#bundle'] = $entity->bundle();
// Let other modules make changes to the form.
// Avoid module_invoke_all() to let parameters be taken by reference.
// Avoid \Drupal::moduleHandler()->invokeAll()
// to let parameters be taken by reference.
foreach (Drupal::moduleHandler()->getImplementations('field_attach_form') as $module) {
$function = $module . '_field_attach_form';
$function($entity, $form, $form_state, $langcode);
......@@ -690,7 +691,7 @@ function field_attach_load($entity_type, $entities, $age = FIELD_LOAD_CURRENT, $
// Invoke hook_field_attach_load(): let other modules act on loading the
// entity.
module_invoke_all('field_attach_load', $entity_type, $queried_entities, $age, $options);
Drupal::moduleHandler()->invokeAll('field_attach_load', $entity_type, $queried_entities, $age, $options);
// Build cache data.
if ($cache_write) {
......@@ -823,7 +824,8 @@ function field_attach_extract_form_values(EntityInterface $entity, $form, &$form
field_invoke_method('extractFormValues', _field_invoke_widget_target($form_display), $entity, $form, $form_state, $options);
// Let other modules act on submitting the entity.
// Avoid module_invoke_all() to let $form_state be taken by reference.
// Avoid \Drupal::moduleHandler()->invokeAll()
// to let $form_state be taken by reference.
foreach (Drupal::moduleHandler()->getImplementations('field_attach_extract_form_values') as $module) {
$function = $module . 'field_attach_extract_form_values';
$function($entity, $form, $form_state);
......
......@@ -352,7 +352,7 @@ function field_purge_instance($instance) {
field_info_cache_clear();
// Invoke external hooks after the cache is cleared for API consistency.
module_invoke_all('field_purge_instance', $instance);
Drupal::moduleHandler()->invokeAll('field_purge_instance', array($instance));
}
/**
......@@ -382,7 +382,7 @@ function field_purge_field($field) {
field_info_cache_clear();
// Invoke external hooks after the cache is cleared for API consistency.
module_invoke_all('field_purge_field', $field);
Drupal::moduleHandler()->invokeAll('field_purge_field', array($field));
}
/**
......
......@@ -204,7 +204,7 @@ function file_copy(File $source, $destination = NULL, $replace = FILE_EXISTS_REN
$file->save();
// Inform modules that the file has been copied.
module_invoke_all('file_copy', $file, $source);
Drupal::moduleHandler()->invokeAll('file_copy', array($file, $source));
return $file;
}
......@@ -279,7 +279,7 @@ function file_move(File $source, $destination = NULL, $replace = FILE_EXISTS_REN
$file->save();
// Inform modules that the file has been moved.
module_invoke_all('file_move', $file, $source);
Drupal::moduleHandler()->invokeAll('file_move', array($file, $source));
// Delete the original if it's not in use elsewhere.
if ($delete_source && !file_usage()->listUsage($source)) {
......@@ -323,7 +323,7 @@ function file_validate(File $file, $validators = array()) {
}
// Let other modules perform validation on the new file.
return array_merge($errors, module_invoke_all('file_validate', $file));
return array_merge($errors, Drupal::moduleHandler()->invokeAll('file_validate', array($file)));
}
/**
......
......@@ -258,7 +258,7 @@ function image_file_download($uri) {
// Check that the file exists and is an image.
if ($info = image_get_info($uri)) {
// Check the permissions of the original to grant access to this image.
$headers = module_invoke_all('file_download', $original_uri);
$headers = Drupal::moduleHandler()->invokeAll('file_download', array($original_uri));
// Confirm there's at least one module granting access and none denying access.
if (!empty($headers) && !in_array(-1, $headers)) {
return array(
......
......@@ -497,7 +497,7 @@ function language_save($language) {
$language->is_new = $language_entity->isNew();
// Let other modules modify $language before saved.
module_invoke_all('language_presave', $language);
Drupal::moduleHandler()->invokeAll('language_presave', array($language));
// Assign language properties to language entity.
$language_entity->label = isset($language->name) ? $language->name : '';
......@@ -509,11 +509,11 @@ function language_save($language) {
$language_entity->save();
$t_args = array('%language' => $language->name, '%langcode' => $language->id);
if ($language->is_new) {
module_invoke_all('language_insert', $language);
Drupal::moduleHandler()->invokeAll('language_insert', array($language));
watchdog('language', 'The %language (%langcode) language has been created.', $t_args);
}
else {
module_invoke_all('language_update', $language);
Drupal::moduleHandler()->invokeAll('language_update', array($language));
watchdog('language', 'The %language (%langcode) language has been updated.', $t_args);
}
......@@ -571,7 +571,7 @@ function language_delete($langcode) {
if (isset($languages[$langcode]) && !$languages[$langcode]->locked) {
$language = $languages[$langcode];
module_invoke_all('language_delete', $language);
Drupal::moduleHandler()->invokeAll('language_delete', array($language));
// Remove the language.
entity_delete_multiple('language_entity', array($language->id));
......
......@@ -821,7 +821,7 @@ function node_permission() {
* A query object that has been extended with the Search DB Extender.
*/
function _node_rankings(SelectExtender $query) {
if ($ranking = module_invoke_all('ranking')) {
if ($ranking = Drupal::moduleHandler()->invokeAll('ranking')) {
$tables = &$query->getTables();
foreach ($ranking as $rank => $values) {
if ($node_rank = variable_get('node_rank_' . $rank, 0)) {
......@@ -888,7 +888,7 @@ function node_search_admin() {
// Note: reversed to reflect that higher number = higher ranking.
$options = drupal_map_assoc(range(0, 10));
foreach (module_invoke_all('ranking') as $var => $values) {
foreach (Drupal::moduleHandler()->invokeAll('ranking') as $var => $values) {
$form['content_ranking']['factors']['node_rank_' . $var] = array(
'#title' => $values['title'],
'#type' => 'select',
......@@ -945,7 +945,7 @@ function node_search_execute($keys = NULL, $conditions = NULL) {
// Fetch comments for snippet.
$node->rendered .= ' ' . module_invoke('comment', 'node_update_index', $node, $item->langcode);
$extra = module_invoke_all('node_search_result', $node, $item->langcode);
$extra = Drupal::moduleHandler()->invokeAll('node_search_result', array($node, $item->langcode));
$language = language_load($item->langcode);
$uri = $node->uri();
......@@ -1756,7 +1756,7 @@ function _node_index_node(EntityInterface $node) {
$text = '<h1>' . check_plain($node->label($language->id)) . '</h1>' . $node->rendered;
// Fetch extra data normally not visible.
$extra = module_invoke_all('node_update_index', $node, $language->id);
$extra = Drupal::moduleHandler()->invokeAll('node_update_index', array($node, $language->id));
foreach ($extra as $t) {
$text .= $t;
}
......@@ -2185,7 +2185,7 @@ function node_access_grants($op, $account = NULL) {
}
// Fetch node access grants from other modules.
$grants = module_invoke_all('node_grants', $account, $op);
$grants = Drupal::moduleHandler()->invokeAll('node_grants', array($account, $op));
// Allow modules to alter the assigned grants.
drupal_alter('node_grants', $grants, $account, $op);
......
......@@ -481,14 +481,14 @@ function overlay_set_mode($mode = NULL) {
drupal_add_library('overlay', 'drupal.overlay.parent');
// Allow modules to act upon overlay events.
module_invoke_all('overlay_parent_initialize');
Drupal::moduleHandler()->invokeAll('overlay_parent_initialize');
break;
case 'child':
drupal_add_library('overlay', 'drupal.overlay.child');
// Allow modules to act upon overlay events.
module_invoke_all('overlay_child_initialize');
Drupal::moduleHandler()->invokeAll('overlay_child_initialize');
break;
}
return $overlay_mode;
......
......@@ -109,7 +109,7 @@ function rdf_rdf_namespaces() {
function rdf_get_namespaces() {
$namespaces = array();
// In order to resolve duplicate namespaces by using the earliest defined
// namespace, do not use module_invoke_all().
// namespace, do not use \Drupal::moduleHandler()->invokeAll().
foreach (Drupal::moduleHandler()->getImplementations('rdf_namespaces') as $module) {
$function = $module . '_rdf_namespaces';
if (function_exists($function)) {
......
......@@ -116,7 +116,7 @@ function hook_search_admin() {
// Note: reversed to reflect that higher number = higher ranking.
$options = drupal_map_assoc(range(0, 10));
$ranks = config('node.settings')->get('search_rank');
foreach (module_invoke_all('ranking') as $var => $values) {
foreach (Drupal::moduleHandler()->invokeAll('ranking') as $var => $values) {
$form['content_ranking']['factors'][$var] = array(
'#title' => $values['title'],
'#type' => 'select',
......@@ -213,7 +213,7 @@ function hook_search_execute($keys = NULL, $conditions = NULL) {
// Fetch comments for snippet.
$node->rendered .= ' ' . module_invoke('comment', 'node_update_index', $node, $item->langcode);
$extra = module_invoke_all('node_search_result', $node, $item->langcode);
$extra = Drupal::moduleHandler()->invokeAll('node_search_result', array($node, $item->langcode));
$language = language_load($item->langcode);
$uri = $node->uri();
......@@ -356,7 +356,7 @@ function hook_update_index() {
$text = '<h1>' . check_plain($node->label()) . '</h1>' . $node->rendered;
// Fetch extra data normally not visible
$extra = module_invoke_all('node_update_index', $node);
$extra = Drupal::moduleHandler()->invokeAll('node_update_index', array($node));
foreach ($extra as $t) {
$text .= $t;
}
......
......@@ -305,7 +305,7 @@ function _search_menu_access($name) {
*/
function search_reindex($sid = NULL, $module = NULL, $reindex = FALSE, $langcode = NULL) {
if ($module == NULL && $sid == NULL) {
module_invoke_all('search_reset');
Drupal::moduleHandler()->invokeAll('search_reset');
}
else {
$query = db_delete('search_dataset')
......
......@@ -368,7 +368,7 @@ function shortcut_default_set($account = NULL) {
// have one, we allow the last module which returns a valid result to take
// precedence. If no module returns a valid set, fall back on the site-wide
// default, which is the lowest-numbered shortcut set.
$suggestions = array_reverse(module_invoke_all('shortcut_default_set', $account));
$suggestions = array_reverse(Drupal::moduleHandler()->invokeAll('shortcut_default_set', array($account)));
$suggestions[] = 'default';
foreach ($suggestions as $name) {
if ($shortcut_set = shortcut_set_load($name)) {
......
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