Problem/Motivation

The commit for #3594081: Convert procedural hooks to object oriented hooks moved hook implementations into
Drupal\token_filter\Hook\TokenFilterHooks and registered it as an autowired service in token_filter.services.yml. However, the .module file still references
the service by its old-style ID token_filter.hooks, which no longer exists. This causes a fatal error on every page load:

Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException:                                                                                                               
  You have requested a non-existent service "token_filter.hooks".                                                                                                                                    
  in Drupal\Component\DependencyInjection\Container->get()                                                                                                                                           
  (line 159 of core/lib/Drupal/Component/DependencyInjection/Container.php)

This is the same class of bug as Token's #3566706: You have requested a non-existent service "Drupal\\token\\Hook\\TokenHooks".

Steps to reproduce

  1. Install drupal/token_filter:2.x-dev (any commit after June 8 2026)
  2. Clear caches
  3. Visit any page

Proposed resolution

Add a service alias in token_filter.services.yml so the .module file's \Drupal::service('token_filter.hooks') calls resolve correctly:

services:                                                                                                                                                                               
    Drupal\token_filter\Hook\TokenFilterHooks:                                                                                                                                                       
      autoconfigure: true                                                                                                                                                                            
      autowire: true                                                                                                                                                                                 
                                                                                                                                                                                                     
    token_filter.hooks:                                                                                                                                                                              
      alias: Drupal\token_filter\Hook\TokenFilterHooks
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

loze created an issue. See original summary.

loze’s picture

Status: Active » Needs review

darvanen made their first commit to this issue’s fork.

darvanen’s picture

Thanks for following up, however, the alias is not the approach core takes. I've made an adjustment, would you check it please?

loze’s picture

Status: Needs review » Reviewed & tested by the community

My bad, you're right. This looks good. +1

  • darvanen committed 53274e0b on 2.x authored by loze
    fix: #3606688 ServiceNotFoundException: "token_filter.hooks" after OOP...
darvanen’s picture

Status: Reviewed & tested by the community » Fixed

Thanks very much :)

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.

Status: Fixed » Closed (fixed)

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