Problem/Motivation

The Varbase profile implements hook_toolbar_alter() as a procedural function in varbase.profile. Drupal 11 provides object-oriented hooks via the #[Hook] attribute (change record), which are autoloaded and support dependency injection.

Steps to reproduce

Review varbase.profile: hook_toolbar_alter() is a procedural function.

Proposed resolution

Move the runtime hook_toolbar_alter() implementation into an object-oriented hook class Drupal\varbase\Hook\VarbaseHooks using the #[Hook] attribute, with the current user injected via the constructor. The install-phase hooks (hook_install_tasks, hook_install_tasks_alter, hook_form_install_configure_form_alter), hook_requirements() and the install task callback helpers are kept procedural, since they run in the minimal installer environment.

Remaining tasks

  • ✅ Add src/Hook/VarbaseHooks.php (toolbar_alter)
  • ✅ Reduce varbase.profile
  • ➖ Keep install-phase hooks + hook_requirements procedural
  • ✅ Reviewed by a human

User interface changes

None.

API changes

None. Standard hook invoked by core only; see the OOP hooks change record.

Data model changes

None.

Release notes snippet

Converted the Varbase profile hook_toolbar_alter() implementation to a Drupal 11 object-oriented hook class.

Release notes snippet

  • refactor: #3608347 Convert the procedural hooks to OOP hook classes in the Varbase profile

Issue fork varbase-3608347

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 2cc55735 on 9.2.x
    task: #3608347 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

✅ Part of the Varbase 9.2.0 release (tagged varbase-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

✅ Released varbase-9.2.0

Status: Fixed » Closed (fixed)

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