Hook classes are introduced in D11.1

Created on 10 February 2025, 28 days ago

Problem/Motivation

Change-record Support for object oriented hook implementations using autowired services describes how to create a Hook class.

Change-record Improve performance by preventing unnecessary scanning of procedural hooks says:
"Drupal 11.1 enables the use of OOP hooks, which are the future of hooks in Drupal. A backwards-compatibility layer is provided for legacy procedural hooks. "
It describes a new parameter: module_name.hooks_converted: true

Change-record Most procedural hook implementations have been converted to a hook class describes the changes in core itself.

Steps to reproduce

Proposed resolution

Introduce hook classes.

Remaining tasks

- create Hook class for hook_theme and hook_preprocess hook implementations.
- create Hook class for hook_views and hook_field_views hook implementations.
- .. for hook_office_hours
- .. for hook_tokens
- .. for hook_field_type_category
- .. for hook_cron (?)
- When all is done, introduce parameters: module_name.hooks_converted: true

User interface changes

API changes

Data model changes

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇳🇱Netherlands johnv

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

Comments & Activities

Production build 0.71.5 2024