ACrossHookReorderAlter.php

Namespace

Drupal\aaa_hook_order_test\Hook

File

core/modules/system/tests/modules/HookOrder/aaa_hook_order_test/src/Hook/ACrossHookReorderAlter.php

View source
<?php

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

use Drupal\Core\Hook\Attribute\Hook;
use Drupal\Core\Hook\Attribute\ReorderHook;
use Drupal\Core\Hook\Order\Order;

/**
 * Contains alter hook implementations.
 *
 * @see \Drupal\KernelTests\Core\Hook\HookAlterOrderTest::testReorderCrossHookAlter()
 */
class ACrossHookReorderAlter {
  public function baseAlterLast(array &$calls) : void {
    $calls[] = __METHOD__;
  }
  
  /**
   * Implements the base alter hook.
   *
   * This method implements the base alter hook, and has an Order::Last rule.
   * In addition, it is targeted by a #[ReorderHook] for the subtype alter hook.
   *
   * @see self::subtypeAlterLast()
   */
  public function baseAlterLastAlsoIfSubtype(array &$calls) : void {
    $calls[] = __METHOD__;
  }
  public function baseAlterLastIfSubtype(array &$calls) : void {
    $calls[] = __METHOD__;
  }
  
  /**
   * Implements the subtype alter hook.
   *
   * In a call to ->alter(['..base', '..subtype'], ..), this method wants to be
   * called after most other implementations, but not after
   * ::baseAlterLastAlsoIfSubtype().
   *
   * To achieve this, it has a #[ReorderHook] that targets
   * ::baseAlterLastAlsoIfSubtype() in context of the subtype hook, meant to
   * reinforce the Order::Last from that base hook implementation.
   */
  public function subtypeAlterLast(array &$calls) : void {
    $calls[] = __METHOD__;
  }
  public function subtypeAlterLastIfBaseHook(array &$calls) : void {
    $calls[] = __METHOD__;
  }
  public function baseAlter(array &$calls) : void {
    $calls[] = __METHOD__;
  }
  public function subtypeAlter(array &$calls) : void {
    $calls[] = __METHOD__;
  }

}

Classes

Title Deprecated Summary
ACrossHookReorderAlter Contains alter hook implementations.

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