Problem/Motivation

The Varbase API module currently implements its hooks as procedural functions in varbase_api.module. Drupal 11 provides object-oriented hooks via the #[Hook] attribute (see the OOP hooks change record), which are autoloaded 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_api.module.
  2. Note that hook_entity_insert(), hook_ENTITY_TYPE_presave() (for view_presave), hook_entity_operation(), hook_form_FORM_ID_alter() (for oauth2_token_settings) and hook_entity_bundle_create() are implemented procedurally rather than as OOP #[Hook] methods.

Proposed resolution

Move the procedural hook implementations (hook_entity_insert, hook_ENTITY_TYPE_presave for view_presave, hook_entity_operation, hook_form_FORM_ID_alter for oauth2_token_settings, and hook_entity_bundle_create) into a new object-oriented hook class \Drupal\varbase_api\Hook\VarbaseApiHooks, using the #[Hook] attribute, with the required services injected via the constructor. Three non-hook helper functions are 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_api-9.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. The three non-hook helper functions kept in the .module file are unaffected.

Data model changes

  • N/A

Release notes snippet

  • task: #3608326 Remove the #[LegacyHook] shims for full OOP hooks
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 10acbbc5 on 10.1.x
    task: #3608326 Convert the procedural hooks to OOP hook classes in the...

  • rajab natshah committed 14c50890 on 9.2.x
    task: #3608326 Remove the #[LegacyHook] shims for full OOP hooks (9.2.x)
    
rajab natshah’s picture

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

✅ Released varbase_api-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

rajab natshah’s picture

Version: 10.1.x-dev » 9.2.x-dev
rajab natshah’s picture

Status: Fixed » Closed (fixed)

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