Commit 78e5e9bf authored by alexpott's avatar alexpott
Browse files

Issue #2045927 by herom, martin107, ianthomas_uk, Xano, michaellander,...

Issue #2045927 by herom, martin107, ianthomas_uk, Xano, michaellander, Sutharsan: Replace all drupal_alter() deprecated function calls.
parent 966c3302
......@@ -251,7 +251,7 @@ function ajax_render($commands = array()) {
else {
$function = '_drupal_add_' . $type;
$items[$type] = $function();
drupal_alter($type, $items[$type]);
\Drupal::moduleHandler()->alter($type, $items[$type]);
// @todo Inline CSS and JS items are indexed numerically. These can't be
// reliably diffed with array_diff_key(), since the number can change
// due to factors unrelated to the inline content, so for now, we strip
......@@ -301,7 +301,7 @@ function ajax_render($commands = array()) {
}
// Allow modules to alter any Ajax response.
drupal_alter('ajax_render', $commands);
\Drupal::moduleHandler()->alter('ajax_render', $commands);
return Json::encode($commands);
}
......
......@@ -1896,13 +1896,13 @@ function module_invoke($module, $hook) {
/**
* Invokes a hook in all enabled modules that implement it.
*
* All arguments are passed by value. Use drupal_alter() if you need to pass
* arguments by reference.
* All arguments are passed by value. Use \Drupal::moduleHandler()->alter() if
* you need to pass arguments by reference.
*
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
* Use \Drupal::moduleHandler()->invokeAll($hook).
*
* @see drupal_alter()
* @see \Drupal\Core\Extension\ModuleHandler::alter()
* @see \Drupal\Core\Extension\ModuleHandler::invokeAll()
*/
function module_invoke_all($hook) {
......
......@@ -358,7 +358,7 @@ function _drupal_default_html_head() {
*/
function drupal_get_html_head() {
$elements = drupal_add_html_head();
drupal_alter('html_head', $elements);
\Drupal::moduleHandler()->alter('html_head', $elements);
return drupal_render($elements);
}
......@@ -1621,9 +1621,9 @@ function _drupal_add_css($data = NULL, $options = NULL) {
* (optional) An array of CSS files. If no array is provided, the default
* stylesheets array is used instead.
* @param $skip_alter
* (optional) If set to TRUE, this function skips calling drupal_alter() on
* $css, useful when the calling function passes a $css array that has already
* been altered.
* (optional) If set to TRUE, this function skips calling
* \Drupal::moduleHandler->alter() on $css, useful when the calling function
* passes a $css array that has already been altered.
*
* @return
* A string of XHTML CSS tags.
......@@ -1639,7 +1639,7 @@ function drupal_get_css($css = NULL, $skip_alter = FALSE) {
// Allow modules and themes to alter the CSS items.
if (!$skip_alter) {
drupal_alter('css', $css);
\Drupal::moduleHandler()->alter('css', $css);
}
// Sort CSS items, so that they appear in the correct order.
......@@ -2252,9 +2252,9 @@ function drupal_js_defaults($data = NULL) {
* (optional) An array with all JavaScript code. Defaults to the default
* JavaScript array for the given scope.
* @param bool $skip_alter
* (optional) If set to TRUE, this function skips calling drupal_alter() on
* $javascript, useful when the calling function passes a $javascript array
* that has already been altered.
* (optional) If set to TRUE, this function skips calling
* \Drupal::moduleHandler->alter() on $javascript, useful when the calling
* function passes a $javascript array that has already been altered.
* @param bool $is_ajax
* (optional) If set to TRUE, this function is called from an Ajax request and
* adds javascript settings to update ajaxPageState values.
......@@ -2276,7 +2276,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS
// Allow modules to alter the JavaScript.
if (!$skip_alter) {
drupal_alter('js', $javascript);
\Drupal::moduleHandler()->alter('js', $javascript);
}
// Filter out elements of the given scope.
......@@ -2722,7 +2722,7 @@ function drupal_add_library($module, $name, $every_page = NULL) {
if ($library = drupal_get_library($module, $name)) {
// Allow modules and themes to dynamically attach request and context
// specific data for this library; e.g., localization.
drupal_alter('library', $library, $module, $name);
\Drupal::moduleHandler()->alter('library', $library, $module, $name);
// Add all components within the library.
$elements['#attached'] = array(
......@@ -2816,7 +2816,7 @@ function drupal_get_library($extension, $name = NULL) {
throw new \RuntimeException(sprintf('Invalid library definition in %s: %s', $library_file, $e->getMessage()), 0, $e);
}
// Allow modules to alter the module's registered libraries.
drupal_alter('library_info', $libraries[$extension], $extension);
\Drupal::moduleHandler()->alter('library_info', $libraries[$extension], $extension);
}
foreach ($libraries[$extension] as $id => &$library) {
......@@ -3705,7 +3705,7 @@ function drupal_prepare_page($page) {
}
// Modules alter the $page as needed. Blocks are populated into regions like
// 'sidebar_first', 'footer', etc.
drupal_alter('page', $page);
\Drupal::moduleHandler()->alter('page', $page);
// The "main" and "secondary" menus are never part of the page-level render
// array and therefore their cache tags will never bubble up into the page
......@@ -4713,7 +4713,7 @@ function element_info($type) {
$cache[$element_type]['#type'] = $element_type;
}
// Allow modules to alter the element type defaults.
drupal_alter('element_info', $cache);
\Drupal::moduleHandler()->alter('element_info', $cache);
}
return isset($cache[$type]) ? $cache[$type] : array();
......@@ -5154,7 +5154,7 @@ function drupal_get_updaters() {
$updaters = &drupal_static(__FUNCTION__);
if (!isset($updaters)) {
$updaters = \Drupal::moduleHandler()->invokeAll('updater_info');
drupal_alter('updater_info', $updaters);
\Drupal::moduleHandler()->alter('updater_info', $updaters);
uasort($updaters, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement'));
}
return $updaters;
......@@ -5174,7 +5174,7 @@ function drupal_get_filetransfer_info() {
$info = &drupal_static(__FUNCTION__);
if (!isset($info)) {
$info = \Drupal::moduleHandler()->invokeAll('filetransfer_info');
drupal_alter('filetransfer_info', $info);
\Drupal::moduleHandler()->alter('filetransfer_info', $info);
uasort($info, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement'));
}
return $info;
......
......@@ -103,7 +103,7 @@ function entity_get_form_modes($entity_type = NULL) {
list($form_mode_entity_type, $form_mode_name) = explode('.', $form_mode->id(), 2);
$form_modes[$form_mode_entity_type][$form_mode_name] = (array) $form_mode;
}
drupal_alter('entity_form_mode_info', $form_modes);
\Drupal::moduleHandler()->alter('entity_form_mode_info', $form_modes);
\Drupal::cache()->set("entity_form_mode_info:$langcode", $form_modes, Cache::PERMANENT, array('entity_types' => TRUE));
}
}
......@@ -141,7 +141,7 @@ function entity_get_view_modes($entity_type = NULL) {
list($view_mode_entity_type, $view_mode_name) = explode('.', $view_mode->id(), 2);
$view_modes[$view_mode_entity_type][$view_mode_name] = (array) $view_mode;
}
drupal_alter('entity_view_mode_info', $view_modes);
\Drupal::moduleHandler()->alter('entity_view_mode_info', $view_modes);
\Drupal::cache()->set("entity_view_mode_info:$langcode", $view_modes, Cache::PERMANENT, array('entity_types' => TRUE));
}
}
......
......@@ -448,7 +448,7 @@ function file_stream_wrapper_get_instance_by_scheme($scheme) {
function file_create_url($uri) {
// Allow the URI to be altered, e.g. to serve a file from a CDN or static
// file server.
drupal_alter('file_url', $uri);
\Drupal::moduleHandler()->alter('file_url', $uri);
$scheme = file_uri_scheme($uri);
......
......@@ -20,7 +20,7 @@ function file_mimetype_mapping() {
if (!isset($mapping)) {
$mapping = file_default_mimetype_mapping();
// Allow modules to alter the default mapping.
drupal_alter('file_mimetype_mapping', $mapping);
\Drupal::moduleHandler()->alter('file_mimetype_mapping', $mapping);
}
return $mapping;
}
......
......@@ -3257,7 +3257,7 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = NU
// The batch is now completely built. Allow other modules to make changes
// to the batch so that it is easier to reuse batch processes in other
// environments.
drupal_alter('batch', $batch);
\Drupal::moduleHandler()->alter('batch', $batch);
// Assign an arbitrary id: don't rely on a serial column in the 'batch'
// table, since non-progressive batches skip database storage completely.
......
......@@ -162,7 +162,7 @@ function drupal_mail($module, $key, $to, $langcode, $params = array(), $reply =
}
// Invoke hook_mail_alter() to allow all modules to alter the resulting e-mail.
drupal_alter('mail', $message);
\Drupal::moduleHandler()->alter('mail', $message);
// Retrieve the responsible implementation for this message.
$system = drupal_mail_system($module, $key);
......
......@@ -485,7 +485,7 @@ function menu_get_item($path = NULL, $router_item = NULL) {
if ($router_item) {
// Allow modules to alter the router item before it is translated and
// checked for access.
drupal_alter('menu_get_item', $router_item, $path, $original_map);
\Drupal::moduleHandler()->alter('menu_get_item', $router_item, $path, $original_map);
$map = _menu_translate($router_item, $original_map);
$router_item['original_map'] = $original_map;
......@@ -903,7 +903,7 @@ function _menu_link_translate(&$item) {
// options array. For performance reasons we only invoke this hook if the link
// has the 'alter' flag set in the options array.
if (!empty($item['options']['alter'])) {
drupal_alter('translated_menu_link', $item, $map);
\Drupal::moduleHandler()->alter('translated_menu_link', $item, $map);
}
}
......@@ -2451,7 +2451,7 @@ function menu_router_build($save = FALSE) {
}
}
// Alter the menu as defined in modules, keys are like user/%user.
drupal_alter('menu', $callbacks);
\Drupal::moduleHandler()->alter('menu', $callbacks);
\Drupal::configFactory()->setOverrideState($old_state);
foreach ($callbacks as $path => $router_item) {
// If the menu item is a default local task and incorrectly references a
......
......@@ -116,8 +116,9 @@ function system_list_reset() {
// Clear the library info cache.
// Libraries may be provided by all extension types, and may be altered by any
// other extensions (types) due to the nature of drupal_alter() and the fact
// that profiles are recorded and handled as modules.
// other extensions (types) due to the nature of
// \Drupal\Core\Extension\ModuleHandler::alter() and the fact that profiles
// are recorded and handled as modules.
Cache::invalidateTags(array('extension' => TRUE));
// Remove last known theme data state.
......
......@@ -160,7 +160,7 @@ function path_get_admin_paths() {
$patterns = &drupal_static(__FUNCTION__);
if (!isset($patterns)) {
$paths = \Drupal::moduleHandler()->invokeAll('admin_paths');
drupal_alter('admin_paths', $paths);
\Drupal::moduleHandler()->alter('admin_paths', $paths);
// Combine all admin paths into one array, and likewise for non-admin paths,
// for easier handling.
$patterns = array();
......
......@@ -86,7 +86,7 @@ function drupal_get_complete_schema($rebuild = FALSE) {
_drupal_schema_initialize($current, $module);
$schema = array_merge($schema, $current);
}
drupal_alter('schema', $schema);
\Drupal::moduleHandler()->alter('schema', $schema);
if ($rebuild) {
Cache::deleteTags(array('schema' => TRUE));
......
......@@ -2031,7 +2031,7 @@ function _template_preprocess_default_variables() {
}
// Give modules a chance to alter the default template variables.
drupal_alter('template_preprocess_default_variables', $variables);
\Drupal::moduleHandler()->alter('template_preprocess_default_variables', $variables);
return $variables;
}
......
......@@ -75,9 +75,10 @@ function _drupal_maintenance_theme() {
$themes = list_themes();
// list_themes() triggers a drupal_alter() in maintenance mode, but we can't
// let themes alter the .info.yml data until we know a theme's base themes. So
// don't set global $theme until after list_themes() builds its cache.
// list_themes() triggers a \Drupal\Core\Extension\ModuleHandler::alter() in
// maintenance mode, but we can't let themes alter the .info.yml data until
// we know a theme's base themes. So don't set global $theme until after
// list_themes() builds its cache.
$theme = $custom_theme;
// Store the identifier for retrieving theme settings with.
......
......@@ -106,7 +106,7 @@ protected function ajaxRender(Request $request) {
else {
$function = '_drupal_add_' . $type;
$items[$type] = $function();
drupal_alter($type, $items[$type]);
\Drupal::moduleHandler()->alter($type, $items[$type]);
// @todo Inline CSS and JS items are indexed numerically. These can't be
// reliably diffed with array_diff_key(), since the number can change
// due to factors unrelated to the inline content, so for now, we
......@@ -166,7 +166,7 @@ protected function ajaxRender(Request $request) {
}
$commands = $this->commands;
drupal_alter('ajax_render', $commands);
\Drupal::moduleHandler()->alter('ajax_render', $commands);
return $commands;
}
......
......@@ -391,7 +391,7 @@ public function preExecute(SelectInterface $query = NULL) {
foreach ($this->alterTags as $tag => $value) {
$hooks[] = 'query_' . $tag;
}
drupal_alter($hooks, $query);
\Drupal::moduleHandler()->alter($hooks, $query);
}
$this->prepared = TRUE;
......
......@@ -209,7 +209,7 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la
// Allow modules to change the view mode.
$entity_view_mode = $view_mode;
drupal_alter('entity_view_mode', $entity_view_mode, $entity, $context);
$this->moduleHandler->alter('entity_view_mode', $entity_view_mode, $entity, $context);
// Store entities for rendering by view_mode.
$view_modes[$entity_view_mode][$entity->id()] = $entity;
}
......@@ -248,7 +248,7 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la
$build[$key]['#weight'] = $weight++;
// Allow modules to modify the render array.
drupal_alter(array($view_hook, 'entity_view'), $build[$key], $entity, $display);
$this->moduleHandler->alter(array($view_hook, 'entity_view'), $build[$key], $entity, $display);
}
return $build;
......
......@@ -261,7 +261,7 @@ protected function formSingleElement(FieldItemListInterface $items, $delta, arra
'delta' => $delta,
'default' => !empty($entity->field_ui_default_value),
);
drupal_alter(array('field_widget_form', 'field_widget_' . $this->getPluginId() . '_form'), $element, $form_state, $context);
\Drupal::moduleHandler()->alter(array('field_widget_form', 'field_widget_' . $this->getPluginId() . '_form'), $element, $form_state, $context);
}
return $element;
......
......@@ -27,7 +27,7 @@ protected function readLanguageOverrides($langcode) {
parent::readLanguageOverrides($langcode);
// Let modules alter the language-specific overrides.
drupal_alter('transliteration_overrides', $this->languageOverrides[$langcode], $langcode);
\Drupal::moduleHandler()->alter('transliteration_overrides', $this->languageOverrides[$langcode], $langcode);
}
}
......@@ -405,7 +405,7 @@ public function buildContentsCssJSSetting(EditorEntity $editor) {
drupal_get_path('module', 'ckeditor') . '/css/ckeditor-iframe.css',
drupal_get_path('module', 'system') . '/css/system.module.css',
);
drupal_alter('ckeditor_css', $css, $editor);
$this->moduleHandler->alter('ckeditor_css', $css, $editor);
$css = array_merge($css, _ckeditor_theme_css());
$css = array_map('file_create_url', $css);
......
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