Change record status: 
Project: 
Introduced in branch: 
11.3.x
Introduced in version: 
11.3.0
Description: 

Theme engine extensions have been deprecated. Theme engines must now be a tagged services in modules.

In a module implement \Drupal\Core\Theme\ThemeEngineInterface
Tag the service as a theme_engine:

  Drupal\Core\Template\TwigThemeEngine:
    class: Drupal\Core\Template\TwigThemeEngine
    autowire: true
    tags:
      - { name: theme_engine, engine_name: twig }

If your theme depends on a custom engine you will need to do the following.

  • Add a dependency to the module providing the dependency.
  • Ensure the module gets installed as part of the conversion otherwise it will not be available

Theme engines no longer support preprocess hooks.
Any preprocess hooks implemented by the theme engine should be moved to the module providing the new theme engine service.

The ThemeManager service now requires the set of theme_engine services to be passed into the constructor as a service locator:

    #[AutowireLocator('theme_engine', 'engine_name')]
    protected ContainerInterface $themeEngines,
Impacts: 
Module developers
Themers
Site templates, recipes and distribution developers