class LegacyHook

Defines a LegacyHook attribute object.

This allows contrib and core to maintain legacy hook implementations alongside the new attribute-based hooks. This means that a contrib module can simultaneously support Drupal 11 and older versions of Drupal that only support procedural hooks.

Marking a procedural hook as #LegacyHook will prevent duplicate executions of attribute-based hooks.

On older versions of Drupal which are not aware of attribute-based hooks, only the legacy hook implementation is executed.

For more information, see https://www.drupal.org/node/3442349.

Hierarchy

Expanded class hierarchy of LegacyHook

3 files declare their use of LegacyHook
HookCollectorPass.php in core/lib/Drupal/Core/Hook/HookCollectorPass.php
legacy_hook_test.module in core/modules/system/tests/modules/legacy_hook_test/legacy_hook_test.module
ModuleHandler.php in core/lib/Drupal/Core/Extension/ModuleHandler.php

File

core/lib/Drupal/Core/Hook/Attribute/LegacyHook.php, line 23

Namespace

Drupal\Core\Hook\Attribute
View source
class LegacyHook {

}

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