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 theVarbaseMediaHooksservice. 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
Issue fork varbase_media-3608373
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 #3
rajab natshahComment #7
rajab natshah✅ Released varbase_media-9.2.0
Comment #9
rajab natshahComment #10
rajab natshahComment #11
rajab natshah✅ Released varbase-9.2.0
Comment #12
rajab natshahComment #13
rajab natshah✅ Released varbase_media-10.1.2