Closed (fixed)
Project:
Taxonomy Term Glossary
Version:
4.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
26 Feb 2026 at 21:36 UTC
Updated:
12 Mar 2026 at 22:40 UTC
Jump to comment: Most recent
Comments
Comment #3
mably commentedOOP hooks conversion
Converted all procedural hooks in
term_glossaryandterm_glossary_per_nodeto OOP classes using#[Hook]attributes, with#[LegacyHook]delegations in the.modulefiles for Drupal 10.x backward compatibility. Dropped Drupal 9 support (core_version_requirementbumped to^10.3 || ^11).New files
src/Hook/TermGlossaryHooks.php— main module hook class with constructor-injectedTermGlossaryManagerInterfaceandRendererInterface. Hooks converted:hook_helphook_themehook_field_formatter_third_party_settings_formhook_field_formatter_settings_summary_alterhook_preprocess_fieldThe old
_term_glossary_check_formatter()helper becomes a private method on the class.modules/term_glossary_per_node/src/Hook/TermGlossaryPerNodeHooks.php— submodule hook class with constructor-injectedEntityTypeManagerInterfaceandAccountProxyInterface. Hooks converted:hook_helphook_entity_bundle_field_infohook_form_node_type_form_alterhook_entity_base_field_infohook_form_node_form_alterThe old procedural callbacks (
form_builder,validate_handler) become public methods on the class (required because they are referenced as[$this, 'method']callables).Modified files
term_glossary.module— rewritten to#[LegacyHook]stubs delegating toTermGlossaryHooks.modules/term_glossary_per_node/term_glossary_per_node.module— same pattern, delegating toTermGlossaryPerNodeHooks.term_glossary.services.yml— added interface alias (TermGlossaryManagerInterface: '@term_glossary.manager') so autowiring can resolve the dependency, and explicit registration ofTermGlossaryHooksfor Drupal 10.x compatibility (on 11.x,HookCollectorPassauto-registers it but the manual entry is harmless).*.info.ymlfiles —core_version_requirementchanged from^9 || ^10 || ^11to^10.3 || ^11(main module + 3 submodules).New file
modules/term_glossary_per_node/term_glossary_per_node.services.yml— registersTermGlossaryPerNodeHookswithautowire: truefor Drupal 10.x compatibility.Unit tests
tests/src/Unit/Hook/TermGlossaryHooksTest.php— 6 tests, 20 assertions coveringTermGlossaryHooks:text_default) delegates to the manager service; incompatible formatter returns an empty array and the manager is never called.elsebranch and adds "Vocabulary: …".getHandler(); full happy path verifies markup replacement, cache tag merging (config + taxonomy term tags), and library attachment.Dependencies (
TermGlossaryManagerInterface,RendererInterface) are mocked — pure unit tests with no Drupal bootstrap.Comment #5
mably commented