Skip to content

Lazy load EscaperRuntime in EscaperExtension#4795

Open
GromNaN wants to merge 1 commit intotwigphp:3.xfrom
GromNaN:lazy-escaper-runtime
Open

Lazy load EscaperRuntime in EscaperExtension#4795
GromNaN wants to merge 1 commit intotwigphp:3.xfrom
GromNaN:lazy-escaper-runtime

Conversation

@GromNaN
Copy link
Copy Markdown
Contributor

@GromNaN GromNaN commented Apr 30, 2026

This allows overriding EscaperRuntime via a custom runtime loader.

Previously, EscaperExtension::setEnvironment() was calling $environment->getRuntime(EscaperRuntime::class) eagerly. Since this method is called from Environment::__construct(), the runtime was resolved before any custom runtime loader could be injected, making it impossible to override EscaperRuntime.

@GromNaN GromNaN force-pushed the lazy-escaper-runtime branch from 69af2b7 to 7931fdd Compare April 30, 2026 11:36
Previously, setEnvironment() called getRuntime(EscaperRuntime::class) eagerly,
which prevented overriding EscaperRuntime via a custom runtime loader since
Environment::__construct() calls setEnvironment() before any loader can be injected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant