Repository navigation
Description
Context
Some services need on-demand instantiation through the injector (design principle 5). Today there is no clean way to inject the Injector itself: the container holds it under injector (src/Infrastructure/ServiceBasedPlugin.php:246-250), but asking the injector to build a service whose constructor takes Injector fails, because Injector is an interface with no binding.
All three plugins known to be built on this scaffold, including AMP and Web Stories, independently added a static Services locator, and use it inside their own composition roots to reach the injector (Services::get( 'injector' )). Principles 5 and 7 rule out such a locator; the missing capability is the reason it keeps appearing.
Scope
- Make the plugin's own injector injectable: a constructor parameter typed
Injectorreceives the same injector instance the plugin uses, configured by the infrastructure itself rather than by each composition root. - Document the pattern in the composition root as the supported alternative to a static locator.
Out of scope
- Any static service locator.
- Exposing the service container by injection.
Acceptance criteria
- A service whose constructor takes
Injectorreceives the plugin's injector instance; a test fails before the change and passes after. - Custom injectors passed to
ServiceBasedPluginare the ones injected (poka-yoke defaults, principle 3).
Verification
composer test
composer lintImpact on generated plugins
No: this does not change an interface or convention generated plugins rely on.
2026-10-23: the container citation moved from :201-204 to :246-250 (lines as of the fix for this issue).
Activity
schlessera commentedon Oct 23, 2026
Picking this up on branch
feat/22-inject-the-injector.