Verified Commit 356d0192 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3293075 by longwave: Remove deprecated code from ModuleHandlerInterface

(cherry picked from commit fbc8bd2d)
parent b2f6bba5
Loading
Loading
Loading
Loading
+0 −17
Original line number Diff line number Diff line
@@ -321,15 +321,6 @@ protected function buildHookInfo() {
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getImplementations($hook) {
    @trigger_error('ModuleHandlerInterface::getImplementations() is deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. Instead you should use ModuleHandlerInterface::invokeAllWith() for hook invocations, or you should use ModuleHandlerInterface::hasImplementations() to determine if hooks implementations exist. See https://www.drupal.org/node/3000490', E_USER_DEPRECATED);
    $implementations = $this->getImplementationInfo($hook);
    return array_keys($implementations);
  }

  /**
   * {@inheritdoc}
   */
@@ -388,14 +379,6 @@ public function hasImplementations(string $hook, $modules = NULL): bool {
    return !empty(array_intersect((array) $modules, array_keys($implementations)));
  }

  /**
   * {@inheritdoc}
   */
  public function implementsHook($module, $hook) {
    @trigger_error('ModuleHandlerInterface::implementsHook() is deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. Instead you should use ModuleHandlerInterface::hasImplementations()  with the $modules argument. See https://www.drupal.org/node/3000490', E_USER_DEPRECATED);
    return $this->hasImplementations($hook, $module);
  }

  /**
   * {@inheritdoc}
   */
+0 −37
Original line number Diff line number Diff line
@@ -172,24 +172,6 @@ public function loadInclude($module, $type, $name = NULL);
   */
  public function getHookInfo();

  /**
   * Determines which modules are implementing a hook.
   *
   * @param string $hook
   *   The name of the hook (e.g. "help" or "menu").
   *
   * @return array
   *   An array with the names of the modules which are implementing this hook.
   *
   * @deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. Instead you
   *   should use ModuleHandlerInterface::invokeAllWith() for hook invocations
   *   or you should use ModuleHandlerInterface::hasImplementations() to
   *   determine if hooks implementations exist.
   *
   * @see https://www.drupal.org/node/3000490
   */
  public function getImplementations($hook);

  /**
   * Write the hook implementation info to the cache.
   */
@@ -217,25 +199,6 @@ public function resetImplementations();
   */
  public function hasImplementations(string $hook, $modules = NULL): bool;

  /**
   * Returns whether a given module implements a given hook.
   *
   * @param string $module
   *   The name of the module (without the .module extension).
   * @param string $hook
   *   The name of the hook (e.g. "help" or "menu").
   *
   * @return bool
   *   TRUE if the module is both installed and enabled, and the hook is
   *   implemented in that module.
   *
   * @deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. Use the
   *   hasImplementations() methods instead with the $modules argument.
   *
   * @see https://www.drupal.org/node/3000490
   */
  public function implementsHook($module, $hook);

  /**
   * Executes a callback for each implementation of a hook.
   *
+0 −26
Original line number Diff line number Diff line
@@ -320,32 +320,6 @@ public function testImplementsHookModuleEnabled() {
    $this->assertFalse($module_handler->hasImplementations('hook', 'module_handler_test_no_hook'), 'Missing implementation not found.');
  }

  /**
   * Tests deprecation of the ::getImplementations method.
   *
   * @covers ::getImplementations
   * @covers ::getImplementationInfo
   * @covers ::buildImplementationInfo
   *
   * @group legacy
   */
  public function testGetImplementations() {
    $this->expectDeprecation('ModuleHandlerInterface::getImplementations() is deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. Instead you should use ModuleHandlerInterface::invokeAllWith() for hook invocations, or you should use ModuleHandlerInterface::hasImplementations() to determine if hooks implementations exist. See https://www.drupal.org/node/3000490');
    $this->assertEquals(['module_handler_test'], $this->getModuleHandler()->getImplementations('hook'));
  }

  /**
   * Tests deprecation of the ::implementsHook method.
   *
   * @covers ::implementsHook
   *
   * @group legacy
   */
  public function testImplementsHook() {
    $this->expectDeprecation('ModuleHandlerInterface::implementsHook() is deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. Instead you should use ModuleHandlerInterface::hasImplementations()  with the $modules argument. See https://www.drupal.org/node/3000490');
    $this->assertTrue($this->getModuleHandler()->implementsHook('module_handler_test', 'hook'));
  }

  /**
   * Tests hasImplementations.
   *