class LegacyRequirementsHook

Prevents procedural requirements hook from executing.

This allows the use of the legacy hook_requirements() and hook_requirements_alter() alongside the OOP replacements.

Marking requirements hooks as #LegacyRequirementsHook will prevent them from running on Drupal 11.3.0 and later.

Note that Drupal 11.2 supports both legacy and new OOP requirements hooks and will invoke both as this attribute is not recognized there.

On older versions of Drupal which are not aware of the new requirement hooks, only the legacy hook implementation is executed.

Adding this attribute will also skip deprecation messages on Drupal 11.3 and later.

Attributes

#[\Attribute(\Attribute::TARGET_FUNCTION)]

Hierarchy

Expanded class hierarchy of LegacyRequirementsHook

4 files declare their use of LegacyRequirementsHook
HookCollectorPass.php in core/lib/Drupal/Core/Hook/HookCollectorPass.php
module_install_requirements.install in core/modules/system/tests/modules/module_install_requirements/module_install_requirements.install
module_runtime_requirements.install in core/modules/system/tests/modules/module_runtime_requirements/module_runtime_requirements.install
module_update_requirements.install in core/modules/system/tests/modules/module_update_requirements/module_update_requirements.install

File

core/lib/Drupal/Core/Hook/Attribute/LegacyRequirementsHook.php, line 25

Namespace

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

}

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