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
Command icon 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

rajab natshah created an issue. See original summary.

  • rajab natshah committed e266e3ab on 9.2.x
    task: #3608329 Convert the procedural hooks to OOP hook classes in the...
rajab natshah’s picture

Issue summary: View changes
Status: Active » Fixed
Issue tags: +varbase-9.2.0, +varbase_styleguide-9.2.0

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

rajab natshah’s picture

Issue summary: View changes

✅ Released varbase-9.2.0

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.