XyzMissingTargetHooks.php
Namespace
Drupal\xyz_hook_order_test\HookFile
-
core/
modules/ system/ tests/ modules/ HookOrder/ xyz_hook_order_test/ src/ Hook/ XyzMissingTargetHooks.php
View source
<?php
declare (strict_types=1);
namespace Drupal\xyz_hook_order_test\Hook;
use Drupal\aaa_hook_order_test\Hook\AMissingTargetHooks;
use Drupal\bbb_hook_order_test\Hook\BMissingTargetHooks;
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 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.
*
* @see \Drupal\KernelTests\Core\Hook\HookOrderTest::testReorderMissingTarget()
*/
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 {
}
}
Classes
| Title | Deprecated | Summary |
|---|---|---|
| XyzMissingTargetHooks | This class contains attributes to reorder or remove hook implementations. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.