Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. LegacyHook.php

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

  • class \Drupal\Core\Hook\Attribute\LegacyHook

Expanded class hierarchy of LegacyHook

2 files declare their use of LegacyHook
HookCollectorPass.php in core/lib/Drupal/Core/Hook/HookCollectorPass.php
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 {

}
RSS feed
Powered by Drupal