Problem/Motivation
The Vartheme BS5 theme implements its hooks as procedural functions in vartheme_bs5.theme. Drupal 11 provides object-oriented hooks via the #[Hook] attribute (change record), which are autoloaded and support dependency injection. Themes support OOP hook classes as of Drupal 11.2.
Steps to reproduce
Review vartheme_bs5.theme: the alter/registration hooks are procedural functions.
Proposed resolution
Move the convertible procedural hook implementations (hook_theme, hook_library_info_alter, hook_form_alter) into an object-oriented hook class Drupal\vartheme_bs5\Hook\VarthemeBs5Hooks using the #[Hook] attribute, with the theme extension list injected via the constructor. The many preprocess hooks and the vartheme_bs5_process_menu_level() helper are kept procedural in the .theme file.
Remaining tasks
- ✅ Add
src/Hook/VarthemeBs5Hooks.php - ✅ Clean
vartheme_bs5.theme(keep preprocess + helper) - ➖ Keep preprocess hooks procedural
- ❌ Reviewed by a human
User interface changes
None.
API changes
None. These are standard theme hooks invoked by core only; see the OOP hooks change record.
Data model changes
None.
Release notes snippet
Converted the Vartheme BS5 procedural hook_theme, hook_library_info_alter and hook_form_alter implementations to a Drupal 11 object-oriented hook class.
Issue fork vartheme_bs5-3608328
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
rajab natshahComment #5
rajab natshahComment #6
rajab natshah✅ Released vartheme_bs5-4.1.0