diff --git a/core/includes/ajax.inc b/core/includes/ajax.inc
index de6f5d0..0c39ecd 100644
--- a/core/includes/ajax.inc
+++ b/core/includes/ajax.inc
@@ -247,7 +247,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
@@ -297,7 +297,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 drupal_json_encode($commands);
 }
diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 8bbdd91..fa22e03 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -2103,13 +2103,13 @@ function module_implements($hook) {
 /**
  * Invokes a hook in a particular module.
  *
- * 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 as of Drupal 8.0. Use
  *   \Drupal::moduleHandler()->invoke($module, $hook, $args = array()).
  *
- * @see drupal_alter()
+ * @see \Drupal\Core\Extension\ModuleHandler::alter()
  * @see \Drupal\Core\Extension\ModuleHandler::invoke()
  */
 function module_invoke($module, $hook) {
@@ -2122,13 +2122,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 as of 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) {
@@ -2138,17 +2138,6 @@ function module_invoke_all($hook) {
   return \Drupal::moduleHandler()->invokeAll($hook, $args);
 }
 
-/**
- * Passes alterable variables to specific hook_TYPE_alter() implementations.
- *
- * @deprecated as of Drupal 8.0. Use
- *   \Drupal::moduleHandler()->alter($hook).
- *
- * @see \Drupal\Core\Extension\ModuleHandler::alter()
- */
-function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL) {
-  return \Drupal::moduleHandler()->alter($type, $data, $context1, $context2);
-}
 
 /**
  * Determines whether a given module exists.
diff --git a/core/includes/common.inc b/core/includes/common.inc
index 580ef21..68adf92 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -356,7 +356,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);
 }
 
@@ -1604,9 +1604,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.
@@ -1622,7 +1622,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.
@@ -2235,9 +2235,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.
@@ -2259,7 +2259,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.
@@ -2775,7 +2775,7 @@ function drupal_get_library($module, $name = NULL) {
       $module_libraries = array();
     }
     // Allow modules to alter the module's registered libraries.
-    drupal_alter('library_info', $module_libraries, $module);
+    \Drupal::moduleHandler()->alter('library_info', $module_libraries, $module);
 
     foreach ($module_libraries as $key => $data) {
       if (is_array($data)) {
@@ -3560,7 +3560,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);
 
   // If no module has taken care of the main content, add it to the page now.
   // This allows the site to still be usable even if no modules that
@@ -4571,7 +4571,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();
@@ -5019,7 +5019,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;
@@ -5039,7 +5039,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;
diff --git a/core/includes/entity.inc b/core/includes/entity.inc
index 5b7cb3f..4137b24 100644
--- a/core/includes/entity.inc
+++ b/core/includes/entity.inc
@@ -130,7 +130,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);
       cache()->set("entity_form_mode_info:$langcode", $form_modes, Cache::PERMANENT, array('entity_info' => TRUE));
     }
   }
@@ -168,7 +168,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);
       cache()->set("entity_view_mode_info:$langcode", $view_modes, Cache::PERMANENT, array('entity_info' => TRUE));
     }
   }
@@ -645,7 +645,7 @@ function entity_get_render_display(EntityInterface $entity, $view_mode) {
     'bundle' => $bundle,
     'view_mode' => $view_mode,
   );
-  drupal_alter('entity_display', $display, $display_context);
+  \Drupal::moduleHandler()->alter('entity_display', $display, $display_context);
 
   return $display;
 }
@@ -753,7 +753,7 @@ function entity_get_render_form_display(EntityInterface $entity, $form_mode) {
     'bundle' => $bundle,
     'form_mode' => $form_mode,
   );
-  drupal_alter('entity_form_display', $form_display, $form_display_context);
+  \Drupal::moduleHandler()->alter('entity_form_display', $form_display, $form_display_context);
 
   return $form_display;
 }
diff --git a/core/includes/file.inc b/core/includes/file.inc
index e3e9326..b876881 100644
--- a/core/includes/file.inc
+++ b/core/includes/file.inc
@@ -207,7 +207,7 @@ function file_get_stream_wrappers($filter = STREAM_WRAPPERS_ALL) {
       // Add defaults.
       $wrappers[$scheme] += array('type' => STREAM_WRAPPERS_NORMAL);
     }
-    drupal_alter('stream_wrappers', $wrappers);
+    \Drupal::moduleHandler()->alter('stream_wrappers', $wrappers);
     $existing = stream_get_wrappers();
     foreach ($wrappers as $scheme => $info) {
       // We only register classes that implement our interface.
@@ -444,7 +444,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);
 
diff --git a/core/includes/file.mimetypes.inc b/core/includes/file.mimetypes.inc
index 5a16158..b6bd404 100644
--- a/core/includes/file.mimetypes.inc
+++ b/core/includes/file.mimetypes.inc
@@ -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;
 }
diff --git a/core/includes/form.inc b/core/includes/form.inc
index 5d4a943..11f44a6 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -3163,7 +3163,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.
diff --git a/core/includes/mail.inc b/core/includes/mail.inc
index 61dfb7e..b980aa2 100644
--- a/core/includes/mail.inc
+++ b/core/includes/mail.inc
@@ -158,7 +158,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);
diff --git a/core/includes/menu.inc b/core/includes/menu.inc
index d54fe06..6572b1d 100644
--- a/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@ -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;
@@ -944,7 +944,7 @@ function _menu_link_translate(&$item, $translate = FALSE) {
   // 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);
   }
 
   return $map;
@@ -2571,7 +2571,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
diff --git a/core/includes/path.inc b/core/includes/path.inc
index 975dbe8..92788a6 100644
--- a/core/includes/path.inc
+++ b/core/includes/path.inc
@@ -159,7 +159,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();
diff --git a/core/includes/schema.inc b/core/includes/schema.inc
index e086da7..4b436fd 100644
--- a/core/includes/schema.inc
+++ b/core/includes/schema.inc
@@ -91,7 +91,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));
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index bfd1aaf..516e8f7 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -2057,7 +2057,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;
 }
diff --git a/core/includes/theme.maintenance.inc b/core/includes/theme.maintenance.inc
index 96dcd2f..6124e8b 100644
--- a/core/includes/theme.maintenance.inc
+++ b/core/includes/theme.maintenance.inc
@@ -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.
diff --git a/core/lib/Drupal/Core/Ajax/AjaxResponse.php b/core/lib/Drupal/Core/Ajax/AjaxResponse.php
index 85cebb9..6678e7a 100644
--- a/core/lib/Drupal/Core/Ajax/AjaxResponse.php
+++ b/core/lib/Drupal/Core/Ajax/AjaxResponse.php
@@ -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;
   }
diff --git a/core/lib/Drupal/Core/Database/Query/Select.php b/core/lib/Drupal/Core/Database/Query/Select.php
index dde6808..3b16b54 100644
--- a/core/lib/Drupal/Core/Database/Query/Select.php
+++ b/core/lib/Drupal/Core/Database/Query/Select.php
@@ -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;
diff --git a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php
index fb19c4e..2b87e85 100644
--- a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php
+++ b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php
@@ -205,7 +205,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;
 
@@ -245,7 +245,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;
diff --git a/core/lib/Drupal/Core/Field/WidgetBase.php b/core/lib/Drupal/Core/Field/WidgetBase.php
index 683cd76..201845a 100644
--- a/core/lib/Drupal/Core/Field/WidgetBase.php
+++ b/core/lib/Drupal/Core/Field/WidgetBase.php
@@ -260,7 +260,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;
diff --git a/core/lib/Drupal/Core/Transliteration/PHPTransliteration.php b/core/lib/Drupal/Core/Transliteration/PHPTransliteration.php
index 6af4708..675b20c 100644
--- a/core/lib/Drupal/Core/Transliteration/PHPTransliteration.php
+++ b/core/lib/Drupal/Core/Transliteration/PHPTransliteration.php
@@ -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);
   }
 
 }
diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php
index 6b880e3..2d0b4af 100644
--- a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php
+++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php
@@ -404,7 +404,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);
 
diff --git a/core/modules/contextual/contextual.module b/core/modules/contextual/contextual.module
index 3fd2cb9..525db81 100644
--- a/core/modules/contextual/contextual.module
+++ b/core/modules/contextual/contextual.module
@@ -284,7 +284,7 @@ function contextual_pre_render_links($element) {
   $element['#links'] = $links;
 
   // Allow modules to alter the renderable contextual links element.
-  drupal_alter('contextual_links_view', $element, $items);
+  \Drupal::moduleHandler()->alter('contextual_links_view', $element, $items);
 
   // If there are no links, tell drupal_render() to abort rendering.
   if (empty($element['#links'])) {
diff --git a/core/modules/editor/lib/Drupal/editor/Entity/Editor.php b/core/modules/editor/lib/Drupal/editor/Entity/Editor.php
index 27346c9..0cdf734 100644
--- a/core/modules/editor/lib/Drupal/editor/Entity/Editor.php
+++ b/core/modules/editor/lib/Drupal/editor/Entity/Editor.php
@@ -76,7 +76,7 @@ public function __construct(array $values, $entity_type) {
     // Initialize settings, merging module-provided defaults.
     $default_settings = $plugin->getDefaultSettings();
     $default_settings += module_invoke_all('editor_default_settings', $this->editor);
-    drupal_alter('editor_default_settings', $default_settings, $this->editor);
+    \Drupal::moduleHandler()->alter('editor_default_settings', $default_settings, $this->editor);
     $this->settings += $default_settings;
   }
 
diff --git a/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php b/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php
index 558cfde..111a984 100644
--- a/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php
+++ b/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php
@@ -87,7 +87,7 @@ public function getAttachments(array $format_ids) {
     }
 
     // We have all JavaScript settings, allow other modules to alter them.
-    drupal_alter('editor_js_settings', $settings);
+    $this->moduleHandler->alter('editor_js_settings', $settings);
 
     if (empty($attachments['library']) && empty($settings)) {
       return array();
diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/SelectionBase.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/SelectionBase.php
index 0986c17..a8fc4ce 100644
--- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/SelectionBase.php
+++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/SelectionBase.php
@@ -309,7 +309,7 @@ protected function reAlterQuery(AlterableInterface $query, $tag, $base_table) {
 
     $query->alterTags = array($tag => TRUE);
     $query->alterMetaData['base_table'] = $base_table;
-    drupal_alter(array('query', 'query_' . $tag), $query);
+    \Drupal::moduleHandler()->alter(array('query', 'query_' . $tag), $query);
 
     // Restore the tags and metadata.
     $query->alterTags = $old_tags;
diff --git a/core/modules/field/field.deprecated.inc b/core/modules/field/field.deprecated.inc
index 02f60e3..f8f6954 100644
--- a/core/modules/field/field.deprecated.inc
+++ b/core/modules/field/field.deprecated.inc
@@ -486,7 +486,7 @@ function field_attach_view(EntityInterface $entity, EntityViewDisplayInterface $
     'display_options' => $view_mode,
     'langcode' => $langcode,
   );
-  drupal_alter('field_attach_view', $output, $context);
+  \Drupal::moduleHandler()->alter('field_attach_view', $output, $context);
 
   // Reset the _field_view_prepared flag set in field_attach_prepare_view(),
   // in case the same entity is displayed with different settings later in
diff --git a/core/modules/field/field.module b/core/modules/field/field.module
index fc29d92..df9b01b 100644
--- a/core/modules/field/field.module
+++ b/core/modules/field/field.module
@@ -461,7 +461,7 @@ function field_view_field(ContentEntityInterface $entity, $field_name, $display_
       'display_options' => $display_options,
       'langcode' => $entity->language()->id,
     );
-    drupal_alter('field_attach_view', $result, $context);
+    \Drupal::moduleHandler()->alter('field_attach_view', $result, $context);
 
     if (isset($result[$field_name])) {
       $output = $result[$field_name];
diff --git a/core/modules/field/field.views.inc b/core/modules/field/field.views.inc
index 172aee4..e78cd85 100644
--- a/core/modules/field/field.views.inc
+++ b/core/modules/field/field.views.inc
@@ -42,8 +42,8 @@ function field_views_data() {
  *
  * Field modules can implement hook_field_views_data_views_data_alter() to
  * alter the views data on a per field basis. This is weirdly named so as
- * not to conflict with the drupal_alter('field_views_data') in
- * field_views_data.
+ * not to conflict with the \Drupal::moduleHandler()->alter('field_views_data')
+ * in field_views_data.
  */
 function field_views_data_alter(&$data) {
   foreach (field_info_fields() as $field) {
diff --git a/core/modules/field/lib/Drupal/field/FieldInfo.php b/core/modules/field/lib/Drupal/field/FieldInfo.php
index 61663e8..4cc3b9e 100644
--- a/core/modules/field/lib/Drupal/field/FieldInfo.php
+++ b/core/modules/field/lib/Drupal/field/FieldInfo.php
@@ -539,7 +539,7 @@ public function getBundleExtraFields($entity_type, $bundle) {
     // shape of the hook, we have no other way than collecting extra fields on
     // all bundles.
     $extra = $this->moduleHandler->invokeAll('field_extra_fields');
-    drupal_alter('field_extra_fields', $extra);
+    $this->moduleHandler->alter('field_extra_fields', $extra);
     $info = isset($extra[$entity_type][$bundle]) ? $extra[$entity_type][$bundle] : array();
     $info += array('form' => array(), 'display' => array());
 
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php
index 5b2046b..6699f2a 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php
@@ -7,8 +7,12 @@
 
 namespace Drupal\field_ui;
 
+use Drupal\Component\Plugin\PluginManagerBase;
 use Drupal\Core\Field\FieldDefinitionInterface;
 use Drupal\Core\Entity\Display\EntityDisplayInterface;
+use Drupal\Core\Entity\EntityManagerInterface;
+use Drupal\Core\Extension\ModuleHandlerInterface;
+use Drupal\Core\Field\FieldTypePluginManager;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
@@ -22,13 +26,38 @@ class DisplayOverview extends DisplayOverviewBase {
   protected $displayContext = 'view';
 
   /**
+   * Stores the module manager.
+   *
+   * @var \Drupal\Core\Extension\ModuleHandlerInterface
+   */
+  protected $moduleHandler;
+
+  /**
+   * Constructs a new class instance.
+   *
+   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
+   *   The entity manager.
+   * @param \Drupal\Core\Field\FieldTypePluginManager $field_type_manager
+   *   The field type manager.
+   * @param \Drupal\Component\Plugin\PluginManagerBase $plugin_manager
+   *   The widget or formatter plugin manager.
+   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
+   *   The module handler class to use for invoking hooks.
+   */
+  public function __construct(EntityManagerInterface $entity_manager, FieldTypePluginManager $field_type_manager, PluginManagerBase $plugin_manager, ModuleHandlerInterface $module_handler) {
+    parent::__construct($entity_manager, $field_type_manager, $plugin_manager);
+    $this->moduleHandler = $module_handler;
+  }
+
+  /**
    * {@inheritdoc}
    */
   public static function create(ContainerInterface $container) {
     return new static(
       $container->get('entity.manager'),
       $container->get('plugin.manager.field.field_type'),
-      $container->get('plugin.manager.field.formatter')
+      $container->get('plugin.manager.field.formatter'),
+      $container->get('module_handler')
     );
   }
 
@@ -204,7 +233,7 @@ protected function alterSettingsForm(array &$settings_form, $plugin, FieldDefini
       'view_mode' => $this->mode,
       'form' => $form,
     );
-    drupal_alter('field_formatter_settings_form', $settings_form, $form_state, $context);
+    $this->moduleHandler->alter('field_formatter_settings_form', $settings_form, $form_state, $context);
   }
 
   /**
@@ -216,7 +245,7 @@ protected function alterSettingsSummary(array &$summary, $plugin, FieldDefinitio
       'field_definition' => $field_definition,
       'view_mode' => $this->mode,
     );
-    drupal_alter('field_formatter_settings_summary', $summary, $context);
+    $this->moduleHandler->alter('field_formatter_settings_summary', $summary, $context);
   }
 
 }
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php
index 8125b89..b746a5e 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php
@@ -7,8 +7,12 @@
 
 namespace Drupal\field_ui;
 
+use Drupal\Component\Plugin\PluginManagerBase;
 use Drupal\Core\Entity\Display\EntityDisplayInterface;
+use Drupal\Core\Entity\EntityManagerInterface;
+use Drupal\Core\Extension\ModuleHandlerInterface;
 use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\FieldTypePluginManager;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
@@ -22,13 +26,38 @@ class FormDisplayOverview extends DisplayOverviewBase {
   protected $displayContext = 'form';
 
   /**
+   * Stores the module manager.
+   *
+   * @var \Drupal\Core\Extension\ModuleHandlerInterface
+   */
+  protected $moduleHandler;
+
+  /**
+   * Constructs a new class instance.
+   *
+   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
+   *   The entity manager.
+   * @param \Drupal\Core\Field\FieldTypePluginManager $field_type_manager
+   *   The field type manager.
+   * @param \Drupal\Component\Plugin\PluginManagerBase $plugin_manager
+   *   The widget or formatter plugin manager.
+   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
+   *   The module handler to use for invoking hooks.
+   */
+  public function __construct(EntityManagerInterface $entity_manager, FieldTypePluginManager $field_type_manager, PluginManagerBase $plugin_manager, ModuleHandlerInterface $module_handler) {
+    parent::__construct($entity_manager, $field_type_manager, $plugin_manager);
+    $this->moduleHandler = $module_handler;
+  }
+
+  /**
    * {@inheritdoc}
    */
   public static function create(ContainerInterface $container) {
     return new static(
       $container->get('entity.manager'),
       $container->get('plugin.manager.field.field_type'),
-      $container->get('plugin.manager.field.widget')
+      $container->get('plugin.manager.field.widget'),
+      $container->get('module_handler')
     );
   }
 
@@ -156,7 +185,7 @@ protected function alterSettingsForm(array &$settings_form, $plugin, FieldDefini
       'form_mode' => $this->mode,
       'form' => $form,
     );
-    drupal_alter('field_widget_settings_form', $settings_form, $form_state, $context);
+    $this->moduleHandler->alter('field_widget_settings_form', $settings_form, $form_state, $context);
   }
 
   /**
@@ -168,7 +197,7 @@ protected function alterSettingsSummary(array &$summary, $plugin, FieldDefinitio
       'field_definition' => $field_definition,
       'form_mode' => $this->mode,
     );
-    drupal_alter('field_widget_settings_summary', $summary, $context);
+    $this->moduleHandler->alter('field_widget_settings_summary', $summary, $context);
   }
 
 }
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index 892b214..0d1487f 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -659,7 +659,7 @@ function file_file_download($uri, $field_type = 'file') {
           'field' => $field,
           'file' => $file,
         );
-        drupal_alter('file_download_access', $grants, $context);
+        \Drupal::moduleHandler()->alter('file_download_access', $grants, $context);
 
         if (in_array(TRUE, $grants)) {
           // If TRUE is returned, access is granted and no further checks are
diff --git a/core/modules/locale/locale.compare.inc b/core/modules/locale/locale.compare.inc
index 48ba081..6386dd6 100644
--- a/core/modules/locale/locale.compare.inc
+++ b/core/modules/locale/locale.compare.inc
@@ -144,7 +144,7 @@ function locale_translation_project_list() {
     $project_info->processInfoList($projects, $theme_data, 'theme', TRUE, $additional_whitelist);
 
     // Allow other modules to alter projects before fetching and comparing.
-    drupal_alter('locale_translation_projects', $projects);
+    \Drupal::moduleHandler()->alter('locale_translation_projects', $projects);
   }
   return $projects;
 }
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessRecordsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessRecordsTest.php
index 0cd54af..78b402b 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessRecordsTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessRecordsTest.php
@@ -79,7 +79,7 @@ function testNodeAccessRecords() {
     foreach ($operations as $op) {
       $grants = node_test_node_grants($op, $web_user);
       $altered_grants = $grants;
-      drupal_alter('node_grants', $altered_grants, $web_user, $op);
+      \Drupal::moduleHandler()->alter('node_grants', $altered_grants, $web_user, $op);
       $this->assertNotEqual($grants, $altered_grants, format_string('Altered the %op grant for a user.', array('%op' => $op)));
     }
 
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 28ca4f1..9fc4a7b 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -1514,7 +1514,7 @@ function node_access_grants($op, $account = NULL) {
   // Fetch node access grants from other modules.
   $grants = \Drupal::moduleHandler()->invokeAll('node_grants', array($account, $op));
   // Allow modules to alter the assigned grants.
-  drupal_alter('node_grants', $grants, $account, $op);
+  \Drupal::moduleHandler()->alter('node_grants', $grants, $account, $op);
 
   return array_merge(array('all' => array(0)), $grants);
 }
diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module
index bd50676..ead1713 100644
--- a/core/modules/simpletest/simpletest.module
+++ b/core/modules/simpletest/simpletest.module
@@ -519,7 +519,7 @@ function simpletest_test_get_all($module = NULL) {
       }
 
       // Allow modules extending core tests to disable originals.
-      drupal_alter('simpletest', $groups);
+      \Drupal::moduleHandler()->alter('simpletest', $groups);
       cache()->set($cid, $groups);
     }
   }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/AlterTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/AlterTest.php
index 3f6b30c..e02c590 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/AlterTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/AlterTest.php
@@ -10,7 +10,7 @@
 use Drupal\simpletest\WebTestBase;
 
 /**
- * Tests alteration of arguments passed to drupal_alter().
+ * Tests alteration of arguments passed to \Drupal::moduleHandler->alter().
  */
 class AlterTest extends WebTestBase {
 
@@ -24,7 +24,7 @@ class AlterTest extends WebTestBase {
   public static function getInfo() {
     return array(
       'name' => 'Alter hook functionality',
-      'description' => 'Tests alteration of arguments passed to drupal_alter().',
+      'description' => 'Tests alteration of arguments passed to \Drupal::moduleHandler->alter().',
       'group' => 'Common',
     );
   }
@@ -46,13 +46,13 @@ function testDrupalAlter() {
     // Verify alteration of a single argument.
     $array_copy = $array;
     $array_expected = array('foo' => 'Drupal theme');
-    drupal_alter('drupal_alter', $array_copy);
+    \Drupal::moduleHandler()->alter('drupal_alter', $array_copy);
     $this->assertEqual($array_copy, $array_expected, 'Single array was altered.');
 
     $entity_copy = clone $entity;
     $entity_expected = clone $entity;
     $entity_expected->foo = 'Drupal theme';
-    drupal_alter('drupal_alter', $entity_copy);
+    \Drupal::moduleHandler()->alter('drupal_alter', $entity_copy);
     $this->assertEqual($entity_copy, $entity_expected, 'Single object was altered.');
 
     // Verify alteration of multiple arguments.
@@ -63,17 +63,17 @@ function testDrupalAlter() {
     $entity_expected->foo = 'Drupal theme';
     $array2_copy = $array;
     $array2_expected = array('foo' => 'Drupal theme');
-    drupal_alter('drupal_alter', $array_copy, $entity_copy, $array2_copy);
-    $this->assertEqual($array_copy, $array_expected, 'First argument to drupal_alter() was altered.');
-    $this->assertEqual($entity_copy, $entity_expected, 'Second argument to drupal_alter() was altered.');
-    $this->assertEqual($array2_copy, $array2_expected, 'Third argument to drupal_alter() was altered.');
+    \Drupal::moduleHandler()->alter('drupal_alter', $array_copy, $entity_copy, $array2_copy);
+    $this->assertEqual($array_copy, $array_expected, 'First argument to \Drupal::moduleHandler->alter() was altered.');
+    $this->assertEqual($entity_copy, $entity_expected, 'Second argument to \Drupal::moduleHandler->alter() was altered.');
+    $this->assertEqual($array2_copy, $array2_expected, 'Third argument to \Drupal::moduleHandler->alter() was altered.');
 
-    // Verify alteration order when passing an array of types to drupal_alter().
+    // Verify alteration order when passing an array of types to \Drupal::moduleHandler->alter().
     // common_test_module_implements_alter() places 'block' implementation after
     // other modules.
     $array_copy = $array;
     $array_expected = array('foo' => 'Drupal block theme');
-    drupal_alter(array('drupal_alter', 'drupal_alter_foo'), $array_copy);
+    \Drupal::moduleHandler()->alter(array('drupal_alter', 'drupal_alter_foo'), $array_copy);
     $this->assertEqual($array_copy, $array_expected, 'hook_TYPE_alter() implementations ran in correct order.');
   }
 }
diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php
index d4c1039..d17ec0f 100644
--- a/core/modules/system/system.api.php
+++ b/core/modules/system/system.api.php
@@ -1072,13 +1072,13 @@ function hook_mail_alter(&$message) {
  * A module may implement this hook in order to reorder the implementing
  * modules, which are otherwise ordered by the module's system weight.
  *
- * Note that hooks invoked using drupal_alter() can have multiple variations
- * (such as hook_form_alter() and hook_form_FORM_ID_alter()). drupal_alter()
- * will call all such variants defined by a single module in turn. For the
- * purposes of hook_module_implements_alter(), these variants are treated as
- * a single hook. Thus, to ensure that your implementation of
- * hook_form_FORM_ID_alter() is called at the right time, you will have to
- * change the order of hook_form_alter() implementation in
+ * Note that hooks invoked using \Drupal::moduleHandler->alter() can have
+ * multiple variations(such as hook_form_alter() and hook_form_FORM_ID_alter()).
+ * \Drupal::moduleHandler->alter() will call all such variants defined by a
+ * single module in turn. For the purposes of hook_module_implements_alter(),
+ * these variants are treated as a single hook. Thus, to ensure that your
+ * implementation of hook_form_FORM_ID_alter() is called at the right time,
+ * you will have to change the order of hook_form_alter() implementation in
  * hook_module_implements_alter().
  *
  * @param $implementations
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index cb0cb54..6e73090 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -2431,7 +2431,7 @@ function _system_rebuild_module_data() {
     // Invoke hook_system_info_alter() to give installed modules a chance to
     // modify the data in the .info.yml files if necessary.
     $type = 'module';
-    drupal_alter('system_info', $modules[$key]->info, $modules[$key], $type);
+    \Drupal::moduleHandler()->alter('system_info', $modules[$key]->info, $modules[$key], $type);
   }
 
   if (isset($modules[$profile])) {
diff --git a/core/modules/system/tests/modules/common_test/common_test.module b/core/modules/system/tests/modules/common_test/common_test.module
index b3b8ad8..7a92caf 100644
--- a/core/modules/system/tests/modules/common_test/common_test.module
+++ b/core/modules/system/tests/modules/common_test/common_test.module
@@ -81,7 +81,8 @@ function bartik_drupal_alter_alter(&$data, &$arg2 = NULL, &$arg3 = NULL) {
 /**
  * Implements hook_TYPE_alter() on behalf of block module.
  *
- * This is for verifying that drupal_alter(array(TYPE1, TYPE2), ...) allows
+ * This is to verify that
+ * \Drupal::moduleHandler()->alter(array(TYPE1, TYPE2), ...) allows
  * hook_module_implements_alter() to affect the order in which module
  * implementations are executed.
  */
@@ -95,10 +96,11 @@ function block_drupal_alter_foo_alter(&$data, &$arg2 = NULL, &$arg3 = NULL) {
  * @see block_drupal_alter_foo_alter()
  */
 function common_test_module_implements_alter(&$implementations, $hook) {
-  // For drupal_alter(array('drupal_alter', 'drupal_alter_foo'), ...), make the
-  // block module implementations run after all the other modules. Note that
-  // when drupal_alter() is called with an array of types, the first type is
-  // considered primary and controls the module order.
+  // For
+  // \Drupal::moduleHandler()->alter(array('drupal_alter', 'drupal_alter_foo'), ...),
+  // make the block module implementations run after all the other modules. Note
+  // that when \Drupal::moduleHandler->alter() is called with an array of types,
+  // the first type is considered primary and controls the module order.
   if ($hook == 'drupal_alter_alter' && isset($implementations['block'])) {
     $group = $implementations['block'];
     unset($implementations['block']);
diff --git a/core/modules/system/tests/themes/test_theme/test_theme.theme b/core/modules/system/tests/themes/test_theme/test_theme.theme
index 13cb2b9..013ef7d 100644
--- a/core/modules/system/tests/themes/test_theme/test_theme.theme
+++ b/core/modules/system/tests/themes/test_theme/test_theme.theme
@@ -24,7 +24,7 @@ function test_theme_theme_test__suggestion($variables) {
  *
  * The confusing function name here is due to this being an implementation of
  * the alter hook invoked when the 'theme_test' module calls
- * drupal_alter('theme_test_alter').
+ * \Drupal::moduleHandler->alter('theme_test_alter').
  */
 function test_theme_theme_test_alter_alter(&$data) {
   $data = 'test_theme_theme_test_alter_alter was invoked';
diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module
index f35d4ae..c1df97b 100644
--- a/core/modules/toolbar/toolbar.module
+++ b/core/modules/toolbar/toolbar.module
@@ -194,7 +194,7 @@ function ($object) {
   // Get toolbar items from all modules that implement hook_toolbar().
   $items = \Drupal::moduleHandler()->invokeAll('toolbar');
   // Allow for altering of hook_toolbar().
-  drupal_alter('toolbar', $items);
+  \Drupal::moduleHandler()->alter('toolbar', $items);
   // Sort the children.
   uasort($items, 'element_sort');
 
diff --git a/core/modules/update/update.compare.inc b/core/modules/update/update.compare.inc
index 492e650..086faa7 100644
--- a/core/modules/update/update.compare.inc
+++ b/core/modules/update/update.compare.inc
@@ -153,7 +153,7 @@ function update_calculate_project_data($available) {
   // Give other modules a chance to alter the status (for example, to allow a
   // contrib module to provide fine-grained settings to ignore specific
   // projects or releases).
-  drupal_alter('update_status', $projects);
+  \Drupal::moduleHandler()->alter('update_status', $projects);
 
   // Store the site's update status for at most 1 hour.
   \Drupal::keyValueExpirable('update')->setWithExpire('update_project_data', $projects, 3600);
diff --git a/core/modules/xmlrpc/xmlrpc.server.inc b/core/modules/xmlrpc/xmlrpc.server.inc
index 9a5d825..5993a71 100644
--- a/core/modules/xmlrpc/xmlrpc.server.inc
+++ b/core/modules/xmlrpc/xmlrpc.server.inc
@@ -64,7 +64,7 @@ function xmlrpc_server($callbacks) {
   // with those defined by modules implementing the _xmlrpc hook.
   // Built-in methods are overridable.
   $callbacks = array_merge($defaults, (array) $callbacks);
-  drupal_alter('xmlrpc', $callbacks);
+  \Drupal::moduleHandler()->alter('xmlrpc', $callbacks);
   foreach ($callbacks as $key => $callback) {
     // we could check for is_array($callback)
     if (is_int($key)) {
