Problem/Motivation

The Varbase Content Planner submodule (part of the Varbase Workflow project) currently implements its hooks as procedural functions in varbase_content_planner.module. Drupal 11 provides object-oriented hooks via the #[Hook] attribute (see the OOP hooks change record), which are autoloaded, easier to test, and support dependency injection.

Steps to reproduce

N/A — this is a code-quality refactoring task, not a defect. To see the current state:

  1. Open varbase_content_planner.module in the varbase_content_planner submodule.
  2. Note that hook_theme(), hook_theme_suggestions_HOOK_alter() (for item_list) and hook_toolbar_alter() are implemented procedurally rather than as OOP #[Hook] methods.

Proposed resolution

Move the procedural hook implementations (hook_theme, hook_theme_suggestions_HOOK_alter for item_list, and hook_toolbar_alter) into a new object-oriented hook class \Drupal\varbase_content_planner\Hook\VarbaseContentPlannerHooks, using the #[Hook] attribute. hook_preprocess_varbase_item_list() is kept procedural in the .module file.

Remaining tasks

  • ✅ File an issue about this project
  • ✅ Addition/Change/Update/Fix to this project
  • ✅ Testing to ensure no regression
  • ➖ Automated unit/functional testing coverage
  • ➖ Developer Documentation support on feature change/addition
  • ➖ User Guide Documentation support on feature change/addition
  • ➖ UX/UI designer responsibilities
  • ➖ Accessibility and Readability
  • ✅ Reviewed by a human
  • ✅ Code review by maintainers
  • ✅ Full testing and approval
  • ✅ Credit contributors
  • ✅ Review with the product owner
  • ✅ Update Release Notes
  • ✅ Release varbase-9.2.0, varbase_workflow-2.2.0

User interface changes

  • N/A — internal refactor only, no user-facing UI change.

API changes

  • None. These are standard hooks invoked by Drupal core only; converting them to the OOP #[Hook] pattern (https://www.drupal.org/node/3442349) does not change any public API or hook contract.

Data model changes

  • N/A

Release notes snippet

  • task: #3608325 Convert the procedural hooks to OOP hook classes in the Varbase Workflow 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’s picture

Issue summary: View changes

  • rajab natshah committed fb03de5f on 3.1.x
    task: #3608325 Convert the procedural hooks to OOP hook classes in the...

  • rajab natshah committed 6f5bf2d5 on 2.2.x
    task: #3608325 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_workflow-2.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.