Tags: cakephp/bake
Tags
Fix singular/plural variable collision in baked templates (#1075) * Fix singular/plural variable collision in baked templates When baking templates for models where the singular and plural forms are identical (e.g., "news", "sheep", "fish"), the generated foreach loops would incorrectly use the same variable for both the collection and the iteration variable, producing invalid code like: foreach ($news as $news): This fix appends "Item" to the singular variable name when a collision is detected, producing valid code: foreach ($news as $newsItem): Refs https://discourse.cakephp.org/t/paginator-error/12806/4 * Fix additional singular/plural variable collisions - Change suffix from 'Item' to 'Entity' (less likely to collide with model names like 'NewsItem') - Add same fix to ControllerCommand for controller action generation - Add collision detection in view.twig for related entity loops (appends 'Related' suffix when otherSingularVar matches singularVar) - Add collision detection in Controller/add.twig and edit.twig for association list variables (appends 'List' suffix when otherPlural matches singularName) - Add test for ControllerCommand singular/plural collision handling
PreviousNext