Provide hook names constants for Hook Attribute aguments

Created on 31 July 2025, about 1 month ago

Problem/Motivation

After implementing support for Hook Attributes in the changelog https://www.drupal.org/node/3442349 β†’ - now it's much more convenient to manage hooks!

But the exact hook name, description, and the module which provides it, still remains a mystery from the code side ;)

Proposed resolution

Would be great to provide constants with all the hook names from Drupal Core, so attributes like this:

  #[Hook('views_data_alter')]

can become like this:

  #[Hook(Views::HOOK_VIEWS_DATA_ALTER)]

that will automatically give direct relationship, description, autocomplete, typo check, and all other benefits of using constants. What do you think about this idea?

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

✨ Feature request
Status

Active

Version

11.0 πŸ”₯

Component

base system

Created by

πŸ‡¦πŸ‡²Armenia murz Yerevan, Armenia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024