Document the themed-view opt-out, the parser app variable, translator autowiring and PHPStan include merging - #7
Merged
Conversation
…wiring and PHPStan include merging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four Thelia 3 behaviours that cost time in real work and that no skill described yet, plus two follow-ups left open by the previous documentation pass. Each claim was checked against the current core, the Flexy theme and the default-twig theme before being written.
Routes that are not views need
ignore_thelia_viewViewListenersubscribes tokernel.view, so any controller that does not return aResponsegets a themed view rendered for it. A module route with no_viewreachesViewRendererwith an empty view name, which logsNo view foundand throws aNotFoundHttpException— andErrorListenerthen replaces that, in production, with the theme's error page. The endpoint answers a themed 404 and the only trace is one line in the Thelia log.The skills already mentioned the flag for the
/_componentsroute. What was missing is the general rule and the fact that it is one flag with three effects: the view listener, the admin firewall check inControllerListener, and the themed error page inErrorListenerall key on the same request attribute. Opting out therefore also means the route has to guard itself, and has to return a realResponse.The parser's
appis not Symfony'sAppVariableTwigParser::render()puts its ownappin the render context: a plain object withenvironment,request,sessionanddebug, and no methods. A context variable shadows a Twig global, so every template the parser renders sees that stub. Withstrict_variablesoff outside the test environment,app.flashes(...),app.user,app.tokenandapp.localeall resolve to null in silence — which is why the Flexy theme reads flashes asapp.session.flashBag.get(...).The back-office is not in the same position: its controllers render through the injected Twig
Environment, so its templates get the realAppVariableand do useapp.flashes. Whichappyou get depends on who renders the template.TranslatorInterfaceautowires to Thelia's translatorThe core aliases
Symfony\Contracts\Translation\TranslatorInterfacetoThelia\Core\Translation\Translator, so a constructor type-hinting the interface never gets the Symfony one. That translator carries the module and validator catalogs, nottranslations/messages.<locale>.php, so a key defined for the templates comes back unchanged from PHP. The escape hatch is#[Autowire(service: 'translator')], which is what the Flexy theme uses in its controllers, services and forms.The back-office skill already described the two translators; this adds why you get one rather than the other, and how to ask for the other.
A PHPStan
includes:mergespathsArray parameters are merged, not overwritten, so a config that includes the root one and adds its own
pathsanalyses both. Scalars override, so a config that does not restatelevelsilently runs at the included level.paths!:replaces;dump-parametersshows the merged result.Also in this PR
tailwind:build --minifyandasset-map:compile. AssetMapper's dev server follows the debug flag, so a front office deployed without the compile has no CSS and no JavaScript.messenger:consume asyncpost-start hook from the DDEV skill. Thelia 3 does not shipsymfony/messenger, and the Thelia 3 skill already says so.