Convert procedural hooks to object oriented hooks

Created on 14 September 2025, 7 days ago
Updated 16 September 2025, 5 days ago

Problem/Motivation

Drupal is moving to object oriented hooks, which offer better performance, and support dependency injection for better type safety and service mocking for testing.

Object oriented hooks are fully supported in Drupal 11, but there are backwards compatible using the #[LegacyHook], but only as far as 10.1, as that they require service autowiring, which was introduced in that branch.

Steps to reproduce

N/A

Proposed resolution

  1. First, we'll need to drop D9 support from the 4.x branch as service autowiring is required.
  2. Then create Hook classes containing the OO versions of the hook handlers.
  3. Add to services.yml to enable calling from the procedural hooks.
  4. Replace hooks in .module file with calls to the hook services.

Remaining tasks

  • Wait for resolution of D9 support.
  • Implement as above.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

📌 Task
Status

Active

Version

4.0

Component

Code

Created by

🇮🇪Ireland lostcarpark

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024