Loading core/modules/system/tests/modules/HookOrder/aaa_hook_order_test/aaa_hook_order_test.module +10 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,8 @@ /** * Implements hook_test_hook(). * * This implementation has no ordering modifications. */ function aaa_hook_order_test_test_hook(): string { return __FUNCTION__; Loading @@ -18,6 +20,8 @@ function aaa_hook_order_test_test_hook(): string { /** * Implements hook_sparse_test_hook(). * * This implementation has no ordering modifications. */ function aaa_hook_order_test_sparse_test_hook(): string { return __FUNCTION__; Loading @@ -25,6 +29,8 @@ function aaa_hook_order_test_sparse_test_hook(): string { /** * Implements hook_procedural_alter(). * * This implementation has no ordering modifications. */ function aaa_hook_order_test_procedural_alter(array &$calls): void { $calls[] = __FUNCTION__; Loading @@ -32,6 +38,8 @@ function aaa_hook_order_test_procedural_alter(array &$calls): void { /** * Implements hook_procedural_subtype_alter(). * * This implementation has no ordering modifications. */ function aaa_hook_order_test_procedural_subtype_alter(array &$calls): void { $calls[] = __FUNCTION__; Loading @@ -39,6 +47,8 @@ function aaa_hook_order_test_procedural_subtype_alter(array &$calls): void { /** * Implements hook_module_implements_alter(). * * This implementation has no ordering modifications. */ function aaa_hook_order_test_module_implements_alter(array &$implementations, string $hook): void { ModuleImplementsAlter::call($implementations, $hook); Loading core/modules/system/tests/modules/HookOrder/aaa_hook_order_test/src/Hook/AAlterHooks.php +13 −0 Original line number Diff line number Diff line Loading @@ -13,14 +13,27 @@ * By default, these will be called in module order, which is predictable due * to the alphabetical module names. Some of the implementations are reordered * using order attributes. * * @see \Drupal\KernelTests\Core\Hook\HookAlterOrderTest */ class AAlterHooks { /** * Implements hook_test_alter(). * * This implementation changes its order to be after the hooks in module * 'ccc_hook_order_test'. */ #[Hook('test_alter', order: new OrderAfter(modules: ['ccc_hook_order_test']))] public function testAlterAfterC(array &$calls): void { $calls[] = __METHOD__; } /** * Implements hook_test_subtype_alter(). * * This implementation has no ordering modifications. */ #[Hook('test_subtype_alter')] public function testSubtypeAlter(array &$calls): void { $calls[] = __METHOD__; Loading core/modules/system/tests/modules/HookOrder/aaa_hook_order_test/src/Hook/ACrossHookReorderAlter.php +16 −1 Original line number Diff line number Diff line Loading @@ -15,13 +15,16 @@ */ class ACrossHookReorderAlter { /** * Implements hook_test_cross_hook_reorder_base_alter(). */ #[Hook('test_cross_hook_reorder_base_alter', order: Order::Last)] public function baseAlterLast(array &$calls): void { $calls[] = __METHOD__; } /** * Implements the base alter hook. * Implements hook_test_cross_hook_reorder_base_alter(). * * 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. Loading @@ -34,6 +37,9 @@ public function baseAlterLastAlsoIfSubtype(array &$calls): void { $calls[] = __METHOD__; } /** * Implements hook_test_cross_hook_reorder_base_alter(). */ #[ReorderHook('test_cross_hook_reorder_subtype_alter', self::class, 'baseAlterLastIfSubtype', Order::Last)] #[Hook('test_cross_hook_reorder_base_alter')] public function baseAlterLastIfSubtype(array &$calls): void { Loading @@ -56,17 +62,26 @@ public function subtypeAlterLast(array &$calls): void { $calls[] = __METHOD__; } /** * Implements hook_test_cross_hook_reorder_subtype_alter(). */ #[ReorderHook('test_cross_hook_reorder_base_alter', self::class, 'subtypeAlterLastIfBaseHook', Order::Last)] #[Hook('test_cross_hook_reorder_subtype_alter')] public function subtypeAlterLastIfBaseHook(array &$calls): void { $calls[] = __METHOD__; } /** * Implements hook_test_cross_hook_reorder_base_alter(). */ #[Hook('test_cross_hook_reorder_base_alter')] public function baseAlter(array &$calls): void { $calls[] = __METHOD__; } /** * Implements test_cross_hook_reorder_subtype_alter(). */ #[Hook('test_cross_hook_reorder_subtype_alter')] public function subtypeAlter(array &$calls): void { $calls[] = __METHOD__; Loading core/modules/system/tests/modules/HookOrder/aaa_hook_order_test/src/Hook/AHooks.php +44 −4 Original line number Diff line number Diff line Loading @@ -13,34 +13,71 @@ use Drupal\Core\Hook\Attribute\ReorderHook; /** * This class contains hook implementations. * Provides hook implementations for testing the execution order of hooks. * * By default, these will be called in module order, which is predictable due * to the alphabetical module names. Some of the implementations are reordered * using order attributes. * By default, these will be called in module order, which is predictable due to * the alphabetical module names. * * Two attributes are used to change the 'test_hook' implementations in module * ccc_hook_order_test. One is the ReorderHook attribute which is used to put * the \Drupal\ccc_hook_order_test\Hook\CHooks::testHookFirst() first. The other * is RemoveHook which is used to remove * \Drupal\ccc_hook_order_test\Hook\CHooks::testHookRemoved(). Both of those * attributes are declared in \Drupal\ddd_hook_order_test\Hook\DHooks. * * @see \Drupal\KernelTests\Core\Hook\HookOrderTest::testHookOrder() * @see \Drupal\KernelTests\Core\Hook\HookOrderTest::testBothParametersHookOrder() */ class AHooks { /** * Implements hook_test_hook(). * * This implementation has no ordering modifications. */ #[Hook('test_hook')] public function testHook(): string { return __METHOD__; } /** * Implements hook_test_hook(). * * This implementation changes its order to be first. */ #[Hook('test_hook', order: Order::First)] public function testHookFirst(): string { return __METHOD__; } /** * Implements hook_test_hook(). * * This implementation changes its order to be last. */ #[Hook('test_hook', order: Order::Last)] public function testHookLast(): string { return __METHOD__; } /** * Implements hook_test_hook(). * * This implementation changes its order to be after the hooks in module * bbb_hook_order_test. */ #[Hook('test_hook', order: new OrderAfter(modules: ['bbb_hook_order_test']))] public function testHookAfterB(): string { return __METHOD__; } /** * Implements test_both_parameters_hook(). * * This implementation changes its order to be after the hooks in module * bbb_hook_order_test and * \Drupal\ccc_hook_order_test\Hook\CHooks::testBothParametersHook().) */ #[Hook( 'test_both_parameters_hook', order: new OrderAfter( Loading @@ -52,6 +89,9 @@ public function testBothParametersHook(): string { return __METHOD__; } /** * Implements test_procedural_reorder(). */ #[ReorderHook('test_procedural_reorder', ProceduralCall::class, 'bbb_hook_order_test_test_procedural_reorder', Order::First)] #[RemoveHook('test_procedural_reorder', ProceduralCall::class, 'ccc_hook_order_test_test_procedural_reorder')] #[Hook('test_procedural_reorder')] Loading core/modules/system/tests/modules/HookOrder/aaa_hook_order_test/src/Hook/AMissingTargetAlter.php +13 −1 Original line number Diff line number Diff line Loading @@ -7,27 +7,39 @@ use Drupal\Core\Hook\Attribute\Hook; /** * Contains alter hook implementations. * Provides hook implementations for testing the alteration of hooks. * * @see \Drupal\KernelTests\Core\Hook\HookAlterOrderTest::testReorderAlterMissingTarget() */ class AMissingTargetAlter { /** * Implements hook_test_ab_alter(). */ #[Hook('test_ab_alter')] public function testABAlter(array &$calls): void { $calls[] = __METHOD__; } /** * Implements hook_testASupertypeAlter(). */ #[Hook('test_a_supertype_alter')] public function testASupertypeAlter(array &$calls): void { $calls[] = __METHOD__; } /** * Implements hook_test_a_supertype_alter(). */ #[Hook('test_a_supertype_alter')] public function testASupertypeAlterReorderedFirstForBSubtypeByXyz(array &$calls): void { $calls[] = __METHOD__; } /** * Implements hook_test_a_supertype_alter(). */ #[Hook('test_a_supertype_alter')] public function testASupertypeAlterRemovedForBSubtypeByXyz(array &$calls): void { $calls[] = __METHOD__; Loading Loading
core/modules/system/tests/modules/HookOrder/aaa_hook_order_test/aaa_hook_order_test.module +10 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,8 @@ /** * Implements hook_test_hook(). * * This implementation has no ordering modifications. */ function aaa_hook_order_test_test_hook(): string { return __FUNCTION__; Loading @@ -18,6 +20,8 @@ function aaa_hook_order_test_test_hook(): string { /** * Implements hook_sparse_test_hook(). * * This implementation has no ordering modifications. */ function aaa_hook_order_test_sparse_test_hook(): string { return __FUNCTION__; Loading @@ -25,6 +29,8 @@ function aaa_hook_order_test_sparse_test_hook(): string { /** * Implements hook_procedural_alter(). * * This implementation has no ordering modifications. */ function aaa_hook_order_test_procedural_alter(array &$calls): void { $calls[] = __FUNCTION__; Loading @@ -32,6 +38,8 @@ function aaa_hook_order_test_procedural_alter(array &$calls): void { /** * Implements hook_procedural_subtype_alter(). * * This implementation has no ordering modifications. */ function aaa_hook_order_test_procedural_subtype_alter(array &$calls): void { $calls[] = __FUNCTION__; Loading @@ -39,6 +47,8 @@ function aaa_hook_order_test_procedural_subtype_alter(array &$calls): void { /** * Implements hook_module_implements_alter(). * * This implementation has no ordering modifications. */ function aaa_hook_order_test_module_implements_alter(array &$implementations, string $hook): void { ModuleImplementsAlter::call($implementations, $hook); Loading
core/modules/system/tests/modules/HookOrder/aaa_hook_order_test/src/Hook/AAlterHooks.php +13 −0 Original line number Diff line number Diff line Loading @@ -13,14 +13,27 @@ * By default, these will be called in module order, which is predictable due * to the alphabetical module names. Some of the implementations are reordered * using order attributes. * * @see \Drupal\KernelTests\Core\Hook\HookAlterOrderTest */ class AAlterHooks { /** * Implements hook_test_alter(). * * This implementation changes its order to be after the hooks in module * 'ccc_hook_order_test'. */ #[Hook('test_alter', order: new OrderAfter(modules: ['ccc_hook_order_test']))] public function testAlterAfterC(array &$calls): void { $calls[] = __METHOD__; } /** * Implements hook_test_subtype_alter(). * * This implementation has no ordering modifications. */ #[Hook('test_subtype_alter')] public function testSubtypeAlter(array &$calls): void { $calls[] = __METHOD__; Loading
core/modules/system/tests/modules/HookOrder/aaa_hook_order_test/src/Hook/ACrossHookReorderAlter.php +16 −1 Original line number Diff line number Diff line Loading @@ -15,13 +15,16 @@ */ class ACrossHookReorderAlter { /** * Implements hook_test_cross_hook_reorder_base_alter(). */ #[Hook('test_cross_hook_reorder_base_alter', order: Order::Last)] public function baseAlterLast(array &$calls): void { $calls[] = __METHOD__; } /** * Implements the base alter hook. * Implements hook_test_cross_hook_reorder_base_alter(). * * 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. Loading @@ -34,6 +37,9 @@ public function baseAlterLastAlsoIfSubtype(array &$calls): void { $calls[] = __METHOD__; } /** * Implements hook_test_cross_hook_reorder_base_alter(). */ #[ReorderHook('test_cross_hook_reorder_subtype_alter', self::class, 'baseAlterLastIfSubtype', Order::Last)] #[Hook('test_cross_hook_reorder_base_alter')] public function baseAlterLastIfSubtype(array &$calls): void { Loading @@ -56,17 +62,26 @@ public function subtypeAlterLast(array &$calls): void { $calls[] = __METHOD__; } /** * Implements hook_test_cross_hook_reorder_subtype_alter(). */ #[ReorderHook('test_cross_hook_reorder_base_alter', self::class, 'subtypeAlterLastIfBaseHook', Order::Last)] #[Hook('test_cross_hook_reorder_subtype_alter')] public function subtypeAlterLastIfBaseHook(array &$calls): void { $calls[] = __METHOD__; } /** * Implements hook_test_cross_hook_reorder_base_alter(). */ #[Hook('test_cross_hook_reorder_base_alter')] public function baseAlter(array &$calls): void { $calls[] = __METHOD__; } /** * Implements test_cross_hook_reorder_subtype_alter(). */ #[Hook('test_cross_hook_reorder_subtype_alter')] public function subtypeAlter(array &$calls): void { $calls[] = __METHOD__; Loading
core/modules/system/tests/modules/HookOrder/aaa_hook_order_test/src/Hook/AHooks.php +44 −4 Original line number Diff line number Diff line Loading @@ -13,34 +13,71 @@ use Drupal\Core\Hook\Attribute\ReorderHook; /** * This class contains hook implementations. * Provides hook implementations for testing the execution order of hooks. * * By default, these will be called in module order, which is predictable due * to the alphabetical module names. Some of the implementations are reordered * using order attributes. * By default, these will be called in module order, which is predictable due to * the alphabetical module names. * * Two attributes are used to change the 'test_hook' implementations in module * ccc_hook_order_test. One is the ReorderHook attribute which is used to put * the \Drupal\ccc_hook_order_test\Hook\CHooks::testHookFirst() first. The other * is RemoveHook which is used to remove * \Drupal\ccc_hook_order_test\Hook\CHooks::testHookRemoved(). Both of those * attributes are declared in \Drupal\ddd_hook_order_test\Hook\DHooks. * * @see \Drupal\KernelTests\Core\Hook\HookOrderTest::testHookOrder() * @see \Drupal\KernelTests\Core\Hook\HookOrderTest::testBothParametersHookOrder() */ class AHooks { /** * Implements hook_test_hook(). * * This implementation has no ordering modifications. */ #[Hook('test_hook')] public function testHook(): string { return __METHOD__; } /** * Implements hook_test_hook(). * * This implementation changes its order to be first. */ #[Hook('test_hook', order: Order::First)] public function testHookFirst(): string { return __METHOD__; } /** * Implements hook_test_hook(). * * This implementation changes its order to be last. */ #[Hook('test_hook', order: Order::Last)] public function testHookLast(): string { return __METHOD__; } /** * Implements hook_test_hook(). * * This implementation changes its order to be after the hooks in module * bbb_hook_order_test. */ #[Hook('test_hook', order: new OrderAfter(modules: ['bbb_hook_order_test']))] public function testHookAfterB(): string { return __METHOD__; } /** * Implements test_both_parameters_hook(). * * This implementation changes its order to be after the hooks in module * bbb_hook_order_test and * \Drupal\ccc_hook_order_test\Hook\CHooks::testBothParametersHook().) */ #[Hook( 'test_both_parameters_hook', order: new OrderAfter( Loading @@ -52,6 +89,9 @@ public function testBothParametersHook(): string { return __METHOD__; } /** * Implements test_procedural_reorder(). */ #[ReorderHook('test_procedural_reorder', ProceduralCall::class, 'bbb_hook_order_test_test_procedural_reorder', Order::First)] #[RemoveHook('test_procedural_reorder', ProceduralCall::class, 'ccc_hook_order_test_test_procedural_reorder')] #[Hook('test_procedural_reorder')] Loading
core/modules/system/tests/modules/HookOrder/aaa_hook_order_test/src/Hook/AMissingTargetAlter.php +13 −1 Original line number Diff line number Diff line Loading @@ -7,27 +7,39 @@ use Drupal\Core\Hook\Attribute\Hook; /** * Contains alter hook implementations. * Provides hook implementations for testing the alteration of hooks. * * @see \Drupal\KernelTests\Core\Hook\HookAlterOrderTest::testReorderAlterMissingTarget() */ class AMissingTargetAlter { /** * Implements hook_test_ab_alter(). */ #[Hook('test_ab_alter')] public function testABAlter(array &$calls): void { $calls[] = __METHOD__; } /** * Implements hook_testASupertypeAlter(). */ #[Hook('test_a_supertype_alter')] public function testASupertypeAlter(array &$calls): void { $calls[] = __METHOD__; } /** * Implements hook_test_a_supertype_alter(). */ #[Hook('test_a_supertype_alter')] public function testASupertypeAlterReorderedFirstForBSubtypeByXyz(array &$calls): void { $calls[] = __METHOD__; } /** * Implements hook_test_a_supertype_alter(). */ #[Hook('test_a_supertype_alter')] public function testASupertypeAlterRemovedForBSubtypeByXyz(array &$calls): void { $calls[] = __METHOD__; Loading