class XyzMissingTargetHooks

This class contains attributes to reorder or remove hook implementations.

When module 'bbb_hook_order_test' is disabled, but 'xyz_hook_order_test' is enabled, these attributes will target non-existing implementations.

The idea behind the hook names:

  • hook_test_ab_hook() has implementations in modules A and B.
  • hook_test_b_hook() has implementations only in module B. As a consequence, it has no implementations if module B is not installed.

Hierarchy

Expanded class hierarchy of XyzMissingTargetHooks

See also

\Drupal\KernelTests\Core\Hook\HookOrderTest::testReorderMissingTarget()

File

core/modules/system/tests/modules/HookOrder/xyz_hook_order_test/src/Hook/XyzMissingTargetHooks.php, line 26

Namespace

Drupal\xyz_hook_order_test\Hook
View source
class XyzMissingTargetHooks {
  
  /**
   * Hook order attributes that target possibly non-existing implementations.
   *
   * (The targeted methods don't exist if module B is disabled.)
   */
  public function targetABHook() : void {
  }
  
  /**
   * Hook order attributes that target a hook with possibly no implementations.
   *
   * (The target hook has no implementations if module B is disabled.)
   */
  public function targetBHook() : void {
  }
  
  /**
   * Hook order attributes where the target method implements a different hook.
   *
   * For non-alter hooks, such attributes have no effect.
   *
   * This scenario can be relevant if the target method is registered for
   * different hooks in different versions of the target module.
   */
  public function targetUnrelatedHookForBHook() : void {
  }

}

Members

Title Sort descending Modifiers Object type Summary
XyzMissingTargetHooks::targetABHook public function Hook order attributes that target possibly non-existing implementations.
XyzMissingTargetHooks::targetBHook public function Hook order attributes that target a hook with possibly no implementations.
XyzMissingTargetHooks::targetUnrelatedHookForBHook public function Hook order attributes where the target method implements a different hook.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.