From 0f166a7dd7acad1af30b4455cbac1cf7309d7448 Mon Sep 17 00:00:00 2001
From: Max Petyurenko <drupalrv@gmail.com>
Date: Tue, 23 Jul 2013 22:48:36 +0300
Subject: [PATCH] Issue #2045919, by benjy: Replace all module_implements()
 deprecated function calls.

---
 core/includes/bootstrap.inc                            |  2 +-
 core/includes/common.inc                               |  4 ++--
 core/includes/menu.inc                                 |  4 ++--
 core/includes/schema.inc                               |  2 +-
 core/includes/theme.inc                                |  2 +-
 .../Core/Config/Entity/ConfigStorageController.php     |  4 ++--
 .../Drupal/Core/Entity/DatabaseStorageController.php   |  4 ++--
 .../lib/Drupal/Core/Plugin/Discovery/HookDiscovery.php |  2 +-
 .../Drupal/Core/Plugin/Discovery/InfoHookDecorator.php |  2 +-
 core/modules/block/block.module                        |  2 +-
 .../entity_reference/selection/CommentSelection.php    |  2 +-
 core/modules/field/field.attach.inc                    | 10 +++++-----
 core/modules/field/field.crud.inc                      |  2 +-
 core/modules/field/field.info.inc                      |  2 +-
 core/modules/field/field.module                        |  4 ++--
 .../FieldType/LegacyFieldTypeDiscoveryDecorator.php    |  3 ++-
 core/modules/file/file.module                          |  2 +-
 core/modules/help/help.module                          |  2 +-
 core/modules/help/lib/Drupal/help/Tests/HelpTest.php   |  2 +-
 .../node/lib/Drupal/node/NodeFormController.php        |  4 ++--
 .../node/lib/Drupal/node/NodeStorageController.php     |  4 ++--
 .../entity_reference/selection/NodeSelection.php       |  2 +-
 core/modules/node/node.module                          | 12 ++++++------
 core/modules/rdf/rdf.module                            |  2 +-
 core/modules/search/search.module                      |  4 ++--
 .../Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php | 18 +++++++++---------
 .../simpletest/lib/Drupal/simpletest/UnitTestBase.php  |  2 +-
 .../system/lib/Drupal/system/Tests/Common/UrlTest.php  |  3 ++-
 .../lib/Drupal/system/Tests/Module/ModuleApiTest.php   |  2 +-
 .../system/lib/Drupal/system/Tests/Theme/ThemeTest.php |  2 +-
 .../Drupal/system/Tests/Theme/TwigDebugMarkupTest.php  |  2 +-
 .../lib/Drupal/system/Tests/Theme/TwigSettingsTest.php |  2 +-
 core/modules/system/system.api.php                     |  9 +++++----
 core/modules/system/system.module                      |  2 +-
 .../tests/modules/module_test/module_test.file.inc     |  2 +-
 .../lib/Drupal/user/Plugin/views/access/Permission.php |  2 +-
 core/modules/user/user.admin.inc                       |  2 +-
 core/modules/user/user.module                          |  2 +-
 38 files changed, 69 insertions(+), 66 deletions(-)

diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 58aebe9..07b60c9 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -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);
     }
diff --git a/core/includes/common.inc b/core/includes/common.inc
index a4805c0..145692d 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -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);
   }
diff --git a/core/includes/menu.inc b/core/includes/menu.inc
index 08c7aff..c64e58e 100644
--- a/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@ -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) {
diff --git a/core/includes/schema.inc b/core/includes/schema.inc
index 77faade..ac0ffad 100644
--- a/core/includes/schema.inc
+++ b/core/includes/schema.inc
@@ -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.
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 7bff76e..67f6d6d 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -622,7 +622,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.
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
index 7fe3c49..3c8f087 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
@@ -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);
     }
   }
diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
index e2dc1b4..5eeb637 100644
--- a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
+++ b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
@@ -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);
     }
   }
diff --git a/core/lib/Drupal/Core/Plugin/Discovery/HookDiscovery.php b/core/lib/Drupal/Core/Plugin/Discovery/HookDiscovery.php
index 0c77a2f..dce1741 100644
--- a/core/lib/Drupal/Core/Plugin/Discovery/HookDiscovery.php
+++ b/core/lib/Drupal/Core/Plugin/Discovery/HookDiscovery.php
@@ -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;
diff --git a/core/lib/Drupal/Core/Plugin/Discovery/InfoHookDecorator.php b/core/lib/Drupal/Core/Plugin/Discovery/InfoHookDecorator.php
index 7ba8913..8f59989 100644
--- a/core/lib/Drupal/Core/Plugin/Discovery/InfoHookDecorator.php
+++ b/core/lib/Drupal/Core/Plugin/Discovery/InfoHookDecorator.php
@@ -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);
     }
diff --git a/core/modules/block/block.module b/core/modules/block/block.module
index cfbad28..0f481ad 100644
--- a/core/modules/block/block.module
+++ b/core/modules/block/block.module
@@ -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) {
diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/entity_reference/selection/CommentSelection.php b/core/modules/comment/lib/Drupal/comment/Plugin/entity_reference/selection/CommentSelection.php
index 2c3aada..fff8d59 100644
--- a/core/modules/comment/lib/Drupal/comment/Plugin/entity_reference/selection/CommentSelection.php
+++ b/core/modules/comment/lib/Drupal/comment/Plugin/entity_reference/selection/CommentSelection.php
@@ -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);
     }
   }
diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc
index 5ed17ff..2f802aa 100644
--- a/core/modules/field/field.attach.inc
+++ b/core/modules/field/field.attach.inc
@@ -531,7 +531,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);
   }
@@ -633,7 +633,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);
     }
@@ -834,7 +834,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);
   }
@@ -863,7 +863,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);
   }
@@ -904,7 +904,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);
   }
diff --git a/core/modules/field/field.crud.inc b/core/modules/field/field.crud.inc
index ed129df..66e0e4a 100644
--- a/core/modules/field/field.crud.inc
+++ b/core/modules/field/field.crud.inc
@@ -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);
   }
diff --git a/core/modules/field/field.info.inc b/core/modules/field/field.info.inc
index b6b2a95..6058fcf 100644
--- a/core/modules/field/field.info.inc
+++ b/core/modules/field/field.info.inc
@@ -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.
diff --git a/core/modules/field/field.module b/core/modules/field/field.module
index 92a2c45..c1ff581 100644
--- a/core/modules/field/field.module
+++ b/core/modules/field/field.module
@@ -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) {
@@ -882,7 +882,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) {
diff --git a/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/LegacyFieldTypeDiscoveryDecorator.php b/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/LegacyFieldTypeDiscoveryDecorator.php
index 9aa6ab7..7a390ad 100644
--- a/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/LegacyFieldTypeDiscoveryDecorator.php
+++ b/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/LegacyFieldTypeDiscoveryDecorator.php
@@ -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';
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index 70dfdb4..81aeedc 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -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.
diff --git a/core/modules/help/help.module b/core/modules/help/help.module
index 75c15ab..36821c0 100644
--- a/core/modules/help/help.module
+++ b/core/modules/help/help.module
@@ -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(
diff --git a/core/modules/help/lib/Drupal/help/Tests/HelpTest.php b/core/modules/help/lib/Drupal/help/Tests/HelpTest.php
index 5a40fa0..2e94f5d 100644
--- a/core/modules/help/lib/Drupal/help/Tests/HelpTest.php
+++ b/core/modules/help/lib/Drupal/help/Tests/HelpTest.php
@@ -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;
diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php
index db6480e..c9649ef 100644
--- a/core/modules/node/lib/Drupal/node/NodeFormController.php
+++ b/core/modules/node/lib/Drupal/node/NodeFormController.php
@@ -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);
     }
diff --git a/core/modules/node/lib/Drupal/node/NodeStorageController.php b/core/modules/node/lib/Drupal/node/NodeStorageController.php
index c3ccc3c..693b828 100644
--- a/core/modules/node/lib/Drupal/node/NodeStorageController.php
+++ b/core/modules/node/lib/Drupal/node/NodeStorageController.php
@@ -58,7 +58,7 @@ protected function attachLoad(&$queried_entities, $load_revision = FALSE) {
     $this->hookLoadArguments = array($argument);

     // 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);
     }
@@ -66,7 +66,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);
     }
   }
diff --git a/core/modules/node/lib/Drupal/node/Plugin/entity_reference/selection/NodeSelection.php b/core/modules/node/lib/Drupal/node/Plugin/entity_reference/selection/NodeSelection.php
index 04a61bd..5a087a8 100644
--- a/core/modules/node/lib/Drupal/node/Plugin/entity_reference/selection/NodeSelection.php
+++ b/core/modules/node/lib/Drupal/node/Plugin/entity_reference/selection/NodeSelection.php
@@ -34,7 +34,7 @@ public function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
     // 'unpublished'. We need to do that as long as there are no access control
     // modules in use on the site. As long as one access control module is there,
     // it is supposed to handle this check.
-    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('status', NODE_PUBLISHED);
     }
     return $query;
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index d0a928b..5a6d53a 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -2227,7 +2227,7 @@ function node_access_view_all_nodes($account = NULL) {
   }

   // If no modules implement the node access system, access is always TRUE.
-  if (!module_implements('node_grants')) {
+  if (!Drupal::moduleHandler()->getImplementations('node_grants')) {
     $access[$account->id()] = TRUE;
   }
   else {
@@ -2274,7 +2274,7 @@ function node_query_node_access_alter(AlterableInterface $query) {
   if (user_access('bypass node access', $account)) {
     return;
   }
-  if (!count(module_implements('node_grants'))) {
+  if (!count(Drupal::moduleHandler()->getImplementations('node_grants'))) {
     return;
   }
   if ($op == 'view' && node_access_view_all_nodes($account)) {
@@ -2363,7 +2363,7 @@ function node_access_rebuild($batch_mode = FALSE) {
   $access_controller = Drupal::entityManager()->getAccessController('node');
   $access_controller->deleteGrants();
   // Only recalculate if the site is using a node_access module.
-  if (count(module_implements('node_grants'))) {
+  if (count(Drupal::moduleHandler()->getImplementations('node_grants'))) {
     if ($batch_mode) {
       $batch = array(
         'title' => t('Rebuilding content access permissions'),
@@ -2481,7 +2481,7 @@ function node_requirements($phase) {
     // in the {node_access} table, or if there are modules that
     // implement hook_node_grants().
     $grant_count = Drupal::entityManager()->getAccessController('node')->countGrants();
-    if ($grant_count != 1 || count(module_implements('node_grants')) > 0) {
+    if ($grant_count != 1 || count(Drupal::moduleHandler()->getImplementations('node_grants')) > 0) {
       $value = format_plural($grant_count, 'One permission in use', '@count permissions in use', array('@count' => $grant_count));
     }
     else {
@@ -2504,7 +2504,7 @@ function node_requirements($phase) {
 function node_modules_enabled($modules) {
   // Check if any of the newly enabled modules require the node_access table to
   // be rebuilt.
-  if (!node_access_needs_rebuild() && array_intersect($modules, module_implements('node_grants'))) {
+  if (!node_access_needs_rebuild() && array_intersect($modules, Drupal::moduleHandler()->getImplementations('node_grants'))) {
     node_access_needs_rebuild(TRUE);
   }
 }
@@ -2528,7 +2528,7 @@ function node_modules_disabled($modules) {

   // If there remains no more node_access module, rebuilding will be
   // straightforward, we can do it right now.
-  if (node_access_needs_rebuild() && count(module_implements('node_grants')) == 0) {
+  if (node_access_needs_rebuild() && count(Drupal::moduleHandler()->getImplementations('node_grants')) == 0) {
     node_access_rebuild();
   }
 }
diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module
index 23f47d6..72850df 100644
--- a/core/modules/rdf/rdf.module
+++ b/core/modules/rdf/rdf.module
@@ -110,7 +110,7 @@ function rdf_get_namespaces() {
   $namespaces = array();
   // In order to resolve duplicate namespaces by using the earliest defined
   // namespace, do not use module_invoke_all().
-  foreach (module_implements('rdf_namespaces') as $module) {
+  foreach (Drupal::moduleHandler()->getImplementations('rdf_namespaces') as $module) {
     $function = $module . '_rdf_namespaces';
     if (function_exists($function)) {
       $namespaces = NestedArray::mergeDeep($function(), $namespaces);
diff --git a/core/modules/search/search.module b/core/modules/search/search.module
index ba5434f..9e9921b 100644
--- a/core/modules/search/search.module
+++ b/core/modules/search/search.module
@@ -238,7 +238,7 @@ function search_get_info($all = FALSE) {
   $search_hooks = &drupal_static(__FUNCTION__);

   if (!isset($search_hooks)) {
-    foreach (module_implements('search_info') as $module) {
+    foreach (Drupal::moduleHandler()->getImplementations('search_info') as $module) {
       $search_hooks[$module] = call_user_func($module . '_search_info');
       // Use module name as the default value.
       $search_hooks[$module] += array('title' => $module, 'path' => $module);
@@ -537,7 +537,7 @@ function _search_index_truncate(&$text) {
  * Invokes hook_search_preprocess() in modules.
  */
 function search_invoke_preprocess(&$text, $langcode = NULL) {
-  foreach (module_implements('search_preprocess') as $module) {
+  foreach (Drupal::moduleHandler()->getImplementations('search_preprocess') as $module) {
     $text = module_invoke($module, 'search_preprocess', $text, $langcode);
   }
 }
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
index 58da4c3..1171d1e 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
@@ -40,7 +40,7 @@ function testSetUp() {
     $this->assertTrue(function_exists('entity_test_permission'), "$module.module was loaded.");
     // Verify that there is a fixed module list.
     $this->assertIdentical(array_keys(\Drupal::moduleHandler()->getModuleList()), array($module));
-    $this->assertIdentical(module_implements('permission'), array($module));
+    $this->assertIdentical(\Drupal::moduleHandler()->getImplementations('permission'), array($module));

     // Verify that no modules have been installed.
     $this->assertFalse(db_table_exists($table), "'$table' database table not found.");
@@ -56,8 +56,8 @@ function testEnableModulesLoad() {
     $this->assertFalse(module_exists($module), "$module module not found.");
     $list = array_keys(\Drupal::moduleHandler()->getModuleList());
     $this->assertFalse(in_array($module, $list), "$module module not found in the extension handler's module list.");
-    $list = module_implements('permission');
-    $this->assertFalse(in_array($module, $list), "{$module}_permission() in module_implements() not found.");
+    $list = \Drupal::moduleHandler()->getImplementations('permission');
+    $this->assertFalse(in_array($module, $list), "{$module}_permission() in Drupal::moduleHandler()->getImplementations() not found.");

     // Enable the module.
     $this->enableModules(array($module));
@@ -66,8 +66,8 @@ function testEnableModulesLoad() {
     $this->assertTrue(module_exists($module), "$module module found.");
     $list = array_keys(\Drupal::moduleHandler()->getModuleList());
     $this->assertTrue(in_array($module, $list), "$module module found in the extension handler's module list.");
-    $list = module_implements('permission');
-    $this->assertTrue(in_array($module, $list), "{$module}_permission() in module_implements() found.");
+    $list = \Drupal::moduleHandler()->getImplementations('permission');
+    $this->assertTrue(in_array($module, $list), "{$module}_permission() in Drupal::moduleHandler()->getImplementations() found.");
   }

   /**
@@ -81,8 +81,8 @@ function testEnableModulesInstall() {
     $this->assertFalse(module_exists($module), "$module module not found.");
     $list = array_keys(\Drupal::moduleHandler()->getModuleList());
     $this->assertFalse(in_array($module, $list), "$module module not found in the extension handler's module list.");
-    $list = module_implements('permission');
-    $this->assertFalse(in_array($module, $list), "{$module}_permission() in module_implements() not found.");
+    $list = \Drupal::moduleHandler()->getImplementations('permission');
+    $this->assertFalse(in_array($module, $list), "{$module}_permission() in Drupal::moduleHandler()->getImplementations() not found.");

     $this->assertFalse(db_table_exists($table), "'$table' database table not found.");
     $schema = drupal_get_schema($table);
@@ -95,8 +95,8 @@ function testEnableModulesInstall() {
     $this->assertTrue(module_exists($module), "$module module found.");
     $list = array_keys(\Drupal::moduleHandler()->getModuleList());
     $this->assertTrue(in_array($module, $list), "$module module found in the extension handler's module list.");
-    $list = module_implements('permission');
-    $this->assertTrue(in_array($module, $list), "{$module}_permission() in module_implements() found.");
+    $list = \Drupal::moduleHandler()->getImplementations('permission');
+    $this->assertTrue(in_array($module, $list), "{$module}_permission() in Drupal::moduleHandler()->getImplementations() found.");

     $this->assertTrue(db_table_exists($table), "'$table' database table found.");
     $schema = drupal_get_schema($table);
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/UnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/UnitTestBase.php
index b869360..c990234 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/UnitTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/UnitTestBase.php
@@ -15,7 +15,7 @@
  *
  * These tests can not access the database nor files. Calling any Drupal
  * function that needs the database will throw exceptions. These include
- * watchdog(), module_implements(), module_invoke_all() etc.
+ * watchdog(), Drupal::moduleHandler()->getImplementations(), module_invoke_all() etc.
  */
 abstract class UnitTestBase extends TestBase {

diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php
index 249afd4..daf299b 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php
@@ -13,7 +13,8 @@
 /**
  * Tests for URL generation functions.
  *
- * url() calls module_implements(), which may issue a db query, which requires
+ * url() calls Drupal::moduleHandler()->getImplementations(),
+ * which may issue a db query, which requires
  * inheriting from a web test case rather than a unit test case.
  */
 class UrlTest extends WebTestBase {
diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php
index a6322b0..d2d65bc 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php
@@ -81,7 +81,7 @@ protected function assertModuleList(Array $expected_values, $condition) {
   }

   /**
-   * Test module_implements() caching.
+   * Test Drupal::moduleHandler()->getImplementations() caching.
    */
   function testModuleImplements() {
     // Clear the cache.
diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php
index f10d83d..e9173b4 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php
@@ -258,7 +258,7 @@ public function testFindThemeTemplates() {
     $cache = array();

     // Prime the theme cache.
-    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));
     }

diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php
index 38e183b..34675f7 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php
@@ -43,7 +43,7 @@ function testTwigDebugMarkup() {

     $cache = array();
     // Prime the theme cache.
-    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));
     }
     // Create array of Twig templates.
diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigSettingsTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigSettingsTest.php
index f50f110..a764dc9 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigSettingsTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigSettingsTest.php
@@ -84,7 +84,7 @@ function testTwigCacheOverride() {

     $cache = array();
     // Prime the theme cache.
-    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));
     }

diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php
index d395462..152c394 100644
--- a/core/modules/system/system.api.php
+++ b/core/modules/system/system.api.php
@@ -1364,9 +1364,9 @@ function hook_mail_alter(&$message) {
 /**
  * Alter the registry of modules implementing a hook.
  *
- * This hook is invoked during module_implements(). A module may implement this
- * hook in order to reorder the implementing modules, which are otherwise
- * ordered by the module's system weight.
+ * This hook is invoked during Drupal::moduleHandler()->getImplementations().
+ * 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()
@@ -1386,7 +1386,8 @@ function hook_mail_alter(&$message) {
  */
 function hook_module_implements_alter(&$implementations, $hook) {
   if ($hook == 'rdf_mapping') {
-    // Move my_module_rdf_mapping() to the end of the list. module_implements()
+    // Move my_module_rdf_mapping() to the end of the list.
+    // Drupal::moduleHandler()->getImplementations()
     // iterates through $implementations with a foreach loop which PHP iterates
     // in the order that the items were added, so to move an item to the end of
     // the array, we remove it and then add it.
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 5d015ce..f9129c3 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -2716,7 +2716,7 @@ function system_rebuild_module_data() {
 function _system_update_bootstrap_status() {
   $bootstrap_modules = array();
   foreach (bootstrap_hooks() as $hook) {
-    foreach (module_implements($hook) as $module) {
+    foreach (Drupal::moduleHandler()->getImplementations($hook) as $module) {
       $bootstrap_modules[$module] = drupal_get_filename('module', $module);
     }
   }
diff --git a/core/modules/system/tests/modules/module_test/module_test.file.inc b/core/modules/system/tests/modules/module_test/module_test.file.inc
index c0d3ec4..1929941 100644
--- a/core/modules/system/tests/modules/module_test/module_test.file.inc
+++ b/core/modules/system/tests/modules/module_test/module_test.file.inc
@@ -2,7 +2,7 @@

 /**
  * @file
- * A file to test module_implements() loading includes.
+ * A file to test Drupal::moduleHandler()->getImplementations() loading includes.
  */

 /**
diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/access/Permission.php b/core/modules/user/lib/Drupal/user/Plugin/views/access/Permission.php
index 0f4a387..d4e2933 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/views/access/Permission.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/views/access/Permission.php
@@ -68,7 +68,7 @@ public function buildOptionsForm(&$form, &$form_state) {
     $module_info = system_get_info('module');

     // Get list of permissions
-    foreach (module_implements('permission') as $module) {
+    foreach (\Drupal::moduleHandler()->getImplementations('permission') as $module) {
       $permissions = module_invoke($module, 'permission');
       foreach ($permissions as $name => $perm) {
         $perms[$module_info[$module]['name']][$name] = strip_tags($perm['title']);
diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc
index 58063e8..d802130 100644
--- a/core/modules/user/user.admin.inc
+++ b/core/modules/user/user.admin.inc
@@ -125,7 +125,7 @@ function user_admin_permissions($form, $form_state, $rid = NULL) {
   // Get a list of all the modules implementing a hook_permission() and sort by
   // display name.
   $modules = array();
-  foreach (module_implements('permission') as $module) {
+  foreach (Drupal::moduleHandler()->getImplementations('permission') as $module) {
     $modules[$module] = $module_info[$module]['name'];
   }
   asort($modules);
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 924b221..0428ae6 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -1650,7 +1650,7 @@ function user_role_load($rid) {
  */
 function user_permission_get_modules() {
   $permissions = array();
-  foreach (module_implements('permission') as $module) {
+  foreach (Drupal::moduleHandler()->getImplementations('permission') as $module) {
     $perms = module_invoke($module, 'permission');
     foreach ($perms as $key => $value) {
       $permissions[$key] = $module;
--
1.8.3.msysgit.0

