Problem/Motivation
The Varbase Styleguide module implements its hooks as procedural functions in varbase_styleguide.module. Drupal 11 provides object-oriented hooks via the #[Hook] attribute (change record), which are autoloaded and support dependency injection.
Steps to reproduce
Review varbase_styleguide.module: the hooks are procedural functions.
Proposed resolution
Move the hook_page_attachments() and hook_help() implementations into an object-oriented hook class Drupal\varbase_styleguide\Hook\VarbaseStyleguideHooks using the #[Hook] attribute, with the current route match, module handler, filter plugin manager and config factory injected via the constructor. The large hook_styleguide_alter() implementation (which renders demo content and embeds a large static markup template) and its render helpers are kept procedural to keep this change focused and low-risk.
Remaining tasks
- ✅ Add
src/Hook/VarbaseStyleguideHooks.php(page_attachments + help) - ✅ Reduce
varbase_styleguide.module - ➖ Keep
hook_styleguide_alter()and render helpers procedural - ✅ Reviewed by a human
- ✅ Release varbase-9.2.0, varbase_styleguide-9.2.0
User interface changes
None.
API changes
None. Standard hooks invoked by core only; see the OOP hooks change record.
Data model changes
None.
Release notes snippet
Converted the Varbase Styleguide hook_page_attachments() and hook_help() implementations to a Drupal 11 object-oriented hook class.
Release notes snippet
task: #3608329 Convert the procedural hooks to OOP hook classes in the Varbase Style Guide module
Issue fork varbase_styleguide-3608329
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 natshah✅ Released varbase_styleguide-9.2.0
Comment #6
rajab natshah✅ Released varbase-9.2.0