From b9451ccf0ed90c674c6f714de10a71a33a6c7b16 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sun, 22 Jul 2018 22:33:53 +0200 Subject: bake: allow default order by through associated tables --- .../plugins/CustomTheme/src/Template/Bake/Model/table.twig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'fai_gestion/plugins/CustomTheme/src/Template/Bake') diff --git a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Model/table.twig b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Model/table.twig index 788e48f..c4a158c 100644 --- a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Model/table.twig +++ b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Model/table.twig @@ -185,10 +185,14 @@ class {{ name }}Table extends Table */ public function beforeFind(Event $event, Query $query, ArrayObject $options, $primary) { -{%- if BakeExtra.hasOrderOpts(name) %} - +{% if BakeExtra.hasOrderOpts(name) %} $order = $query->clause('order'); if ($order === null || !count($order)) { +{% if BakeExtra.hasOrderContains(name) %} + $query->contain([ + {{- Bake.stringifyList(BakeExtra.getOrderContains(name), {'indent': 4})|raw -}} + ]); +{% endif %} $query->order([ {{- Bake.stringifyList(BakeExtra.getOrderOpts(name), {'indent': 4})|raw -}} ]); -- cgit v1.1