Closed (fixed)
Project:
Toc.js
Version:
3.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
17 Feb 2026 at 15:57 UTC
Updated:
5 Mar 2026 at 10:00 UTC
Jump to comment: Most recent
It's all in the title.
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
mably commentedConvert all hooks to OOP format
Converted all hook implementations across the main module and all sub-modules from procedural
.modulefunctions to OOP classes using#[Hook]attributes, with#[LegacyHook]delegations in.modulefiles for Drupal 10.6 backward compatibility.toc_js (main module) — 7 hooks converted
src/Hook/TocJsHooks.phpwith#[Hook]attributes for:help,theme,theme_suggestions_toc_js_alter,entity_extra_field_info,node_view,form_node_type_form_alter+ static entity builder methodtoc_js.services.ymlto register the hooks class withtoc_js.serviceandcurrent_userdependenciestoc_js.modulewith#[LegacyHook]delegationshook_help()implementation — function was namedtoc_js_node_help()instead oftoc_js_help(), so it was never calledtemplate_preprocess_toc_js()as-is (empty theme preprocess, not a hook)toc_js_filter (sub-module) — 1 hook converted
src/Hook/TocJsFilterHooks.phpwith#[Hook('help')]toc_js_filter.services.ymltoc_js_filter.modulewith#[LegacyHook]toc_js_per_node (sub-module) — 6 hooks converted
src/Hook/TocJsPerNodeHooks.phpwith#[Hook]attributes for:help,entity_extra_field_info,form_node_type_form_alter,entity_bundle_field_info,entity_base_field_info,form_node_form_alter+ static entity builder methodtoc_js_per_node.services.ymlwithcurrent_userdependencytoc_js_per_node.modulewith#[LegacyHook]delegationstoc_js_test_module — 1 hook converted
src/Hook/TocJsTestModuleHooks.phpwith#[Hook('preprocess_node')]toc_js_test_module.services.ymltoc_js_test_module.modulewith#[LegacyHook]Test results
Existing FunctionalJavascript test passes (1 test, 12 assertions). Cache rebuild clean.
Comment #5
mably commentedComment #7
mably commentedConvert all hooks to OOP format using
#[Hook]attributes with#[LegacyHook]backward compatibility for Drupal 10.x, across the main module and both sub-modules (toc_js_filter,toc_js_per_node). Also remove the empty no-optoc_js_requirements()hook.Changes
toc_js.module
hook_help,hook_theme,hook_theme_suggestions_toc_js_alter,hook_entity_extra_field_info,hook_node_view,hook_form_node_type_form_alter, entity builder) now carry#[LegacyHook]and delegate toTocJsHooksOOP service.toc_js_node_help->toc_js_help.toc_js.install
toc_js_requirements()function (returned an empty array for all phases).src/Hook/TocJsHooks.php (new)
TocJsService,AccountProxyInterface).#[Hook('help')],#[Hook('theme')],#[Hook('theme_suggestions_toc_js_alter')],#[Hook('entity_extra_field_info')],#[Hook('node_view')],#[Hook('form_node_type_form_alter')].formNodeTypeFormBuilder()entity builder.toc_js.services.yml
Drupal\toc_js\Hook\TocJsHookswith explicit arguments (@toc_js.service,@current_user).modules/toc_js_filter/toc_js_filter.module
hook_helpnow carries#[LegacyHook]and delegates toTocJsFilterHooks.modules/toc_js_filter/src/Hook/TocJsFilterHooks.php (new)
#[Hook('help')].modules/toc_js_filter/toc_js_filter.services.yml (new)
Drupal\toc_js_filter\Hook\TocJsFilterHooks.modules/toc_js_per_node/toc_js_per_node.module
hook_help,hook_entity_extra_field_info,hook_form_node_type_form_alter,hook_entity_bundle_field_info,hook_entity_base_field_info,hook_form_node_form_alter) now carry#[LegacyHook]and delegate toTocJsPerNodeHooks.modules/toc_js_per_node/src/Hook/TocJsPerNodeHooks.php (new)
AccountProxyInterface).#[Hook]attributes and$this->t()instead of proceduralt().modules/toc_js_per_node/toc_js_per_node.info.yml
drupal:nodedependency (required by the hook class).modules/toc_js_per_node/toc_js_per_node.services.yml (new)
Drupal\toc_js_per_node\Hook\TocJsPerNodeHookswith@current_userargument.tests/modules/toc_js_test_module/toc_js_test_module.module
hook_preprocess_nodenow carries#[LegacyHook]and delegates toTocJsTestModuleHooks.tests/modules/toc_js_test_module/src/Hook/TocJsTestModuleHooks.php (new)
#[Hook('preprocess_node')].tests/modules/toc_js_test_module/toc_js_test_module.services.yml (new)
Drupal\toc_js_test_module\Hook\TocJsTestModuleHooks..gitlab-ci.yml
Backward compatibility
#[LegacyHook]is ignored, procedural functions run normally and delegate to OOP services.#[LegacyHook]prevents procedural functions from running,#[Hook]attributes on OOP methods are called directly by the hook system.