Problem/Motivation

Related to #3525011: Allow complete replacement of the default theme engine (twig) in Drupal core. ComponentPluginManager::alterDefinition() hardcodes the template extension:

$template = $this->findAsset($component_directory, $definition['machineName'], 'twig');

A component whose template is anything but <name>.twig is invisible to discovery, regardless of the active theme engine.

Steps to reproduce

Add a component directory containing only card.jsx (or any non-.twig template) with a valid *.component.yml. ComponentPluginManager reports no template found.

Proposed resolution

Depends on #3625132: Add a template ownership interface so theme engines can tell core which templates they provide. Iterate candidate engines (active theme's engine first, then Twig), asking each for its extension via getExtension() and checking for a matching file. Record the resolving engine on the definition ($definition['engine']) for child D to consume.

Open question to resolve here: SDC templates are named card.twig, but TwigThemeEngine::EXTENSION is .html.twig — the two conventions disagree. Likely resolution: getExtension() returns an ordered list of acceptable extensions rather than a single string.

Remaining tasks

  • Resolve the extension-convention question above
  • Implement engine-aware discovery in alterDefinition()
  • Kernel test: a component directory with both a .twig and an alternate-engine template resolves to whichever engine is active

User interface changes

None.

Introduced terminology

None.

API changes

Component plugin definitions gain an engine key. No BC break: Twig remains a candidate engine, so existing .twig components still resolve.

Data model changes

None.

Release notes snippet

Single Directory Component template discovery can now find templates authored for a non-Twig theme engine.

Comments

matthand created an issue. See original summary.

matthand’s picture

Issue summary: View changes
matthand’s picture

Issue summary: View changes
matthand’s picture

Status: Active » Postponed

Postponed while we seek approvals on plan in parent issue.