Problem/Motivation

The Varbase Media module implements its hooks and helper functions procedurally across varbase_media.module, includes/helpers.inc and varbase_media.tokens.inc. Drupal 11 provides object-oriented hooks via the #[Hook] attribute (change record), which are autoloaded and support dependency injection — the recommended pattern for Drupal ~11.4.0.

Steps to reproduce

Review varbase_media.module, includes/helpers.inc and varbase_media.tokens.inc: the hook implementations, shared helpers and tokens are procedural functions.

Proposed resolution

Move all hook implementations (field/entity preprocess, entity_presave, form alters, theme, theme registry/suggestions, entity_view_alter, media_source_info_alter, oembed_resource_url_alter, entity_embed_alter, library_info_alter, ckeditor_css_alter, token_info, tokens) and the shared helper functions into an object-oriented hook class Drupal\varbase_media\Hook\VarbaseMediaHooks using the #[Hook] attribute, with all required services injected via the constructor. The bulk-upload form submit callback becomes a class method referenced as [$this, 'bulkUploadFormSubmitHandler'] (with DependencySerializationTrait). The varbase_media.module, includes/helpers.inc and varbase_media.tokens.inc files are removed; the update-hook caller in includes/updates/v8.inc is rewired to \Drupal::service(VarbaseMediaHooks::class).

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_media-9.2.0

User interface changes

  • N/A

API changes

  • The procedural helper functions (varbase_media__image_url(), varbase_media__get_node_share_image_url(), varbase_media__default_image_field_name(), varbase_media__get_fallback_social_share_image_url(), varbase_media__managed_media_library_configs(), varbase_media__slick_media_fix_dependencies()) are moved to public methods on the VarbaseMediaHooks service. Standard hooks remain invoked by core only.

Data model changes

  • N/A

Release notes snippet

  • task: #3608373 Convert the remaining procedural helpers/tokens to the OOP hook class and remove the procedural files
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 20a480ff on 10.1.x
    task: #3608373 Convert the procedural hooks and helpers to OOP hook...

  • rajab natshah committed 38e7448c on 9.2.x
    task: #3608373 Convert the remaining procedural helpers/tokens to the...
rajab natshah’s picture

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

✅ Released varbase_media-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
rajab natshah’s picture

Issue summary: View changes
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.