Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor #2456 [TwigComponent] Document about unwanted behavior with `Ex…
…poseInTemplate` and computed methods (Kocal) This PR was merged into the 2.x branch. Discussion ---------- [TwigComponent] Document about unwanted behavior with `ExposeInTemplate` and computed methods | Q | A | ------------- | --- | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - For new features, provide some code snippets to help understand usage. - Features and deprecations must be submitted against branch main. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> As spotted when working on my application, the following code triggers two times the methods `transactions()` because of the presence of `#[ExposeInTemplate]` (because before I used `transactions` instead of `computed.transactions`): ```php #[ExposeInTemplate] public function transactions(): array { // SQL query to database } ``` ```twig {{ computed.transactions|length }} ``` When I remove `#[ExposeInTemplate]`, then only one SQL query is made. Commits ------- 16cd48a [TwigComponent] Document about unwanted behavior with ExposeInTemplate and computed methods
- Loading branch information