XyzMissingTargetAlter.php

Namespace

Drupal\xyz_hook_order_test\Hook

File

core/modules/system/tests/modules/HookOrder/xyz_hook_order_test/src/Hook/XyzMissingTargetAlter.php

View source
<?php

declare (strict_types=1);
namespace Drupal\xyz_hook_order_test\Hook;

use Drupal\aaa_hook_order_test\Hook\AMissingTargetAlter;
use Drupal\bbb_hook_order_test\Hook\BMissingTargetAlter;
use Drupal\Core\Hook\Attribute\RemoveHook;
use Drupal\Core\Hook\Attribute\ReorderHook;
use Drupal\Core\Hook\Order\Order;

/**
 * This class contains attributes to reorder or remove alter implementations.
 *
 * The idea behind the hook names:
 *   - hook_test_ab_alter() has implementations in modules A and B.
 *   - hook_test_b_alter() has implementations only in module B.
 *     As a consequence, it has no implementations if module B is not installed.
 *
 * @see \Drupal\KernelTests\Core\Hook\HookAlterOrderTest::testReorderAlterMissingTarget()
 */
class XyzMissingTargetAlter {
  
  /**
   * Hook order attributes that target possibly non-existing alter methods.
   *
   * (The targeted methods don't exist if module B is disabled.)
   */
  public function targetABAlter() : 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 targetBAlter() : void {
  }
  
  /**
   * Hook order attributes where the target method implements a different hook.
   *
   * This scenario is special for alter hooks, when the alter types for both
   * hooks are passed to ->alter().
   */
  public function targetASupertypeAlterForBSubtypeAlter() : void {
  }

}

Classes

Title Deprecated Summary
XyzMissingTargetAlter This class contains attributes to reorder or remove alter implementations.

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