From 0dd134b71539f38d84db3b023ba42d2650df278a Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Thu, 19 Jul 2018 00:20:03 +0200 Subject: bake: Add configurability, generate less actions --- fai_gestion/config/bake_extra.php | 95 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 fai_gestion/config/bake_extra.php (limited to 'fai_gestion/config/bake_extra.php') diff --git a/fai_gestion/config/bake_extra.php b/fai_gestion/config/bake_extra.php new file mode 100644 index 0000000..e33b2a0 --- /dev/null +++ b/fai_gestion/config/bake_extra.php @@ -0,0 +1,95 @@ + + * Copyright 2016 Nicolas Goaziou + * + * This file is part of FAI Gestion forked from CHD Gestion. + * + * FAI Gestion is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FAI Gestion is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FAI Gestion. If not, see . +**/ +/* + * This config file is used twice when "cake bake all" is run : + * + * -> config/bootstrap_cli.php : Plugin::load('CustomTheme',['bootstrap' => true,...]) + * (1)->plugins/CustomTheme/src/Shell/BakeShell.php + * startup() include this file and set Model->skipTables + * all() set $this->{$task}->params at each task run + * + * So "all" subcommand is limited/tweaked by $skipTables and $taskParams + * + * (2)->plugins/CustomTheme/config/bootstrap.php: + * EventManager::instance()->on('Bake.initialize',...) + * $extra = include(); + * $view->loadHelper('CustomTheme.BakeExtra', $extra); + * EventManager::instance()->on('Bake.beforeRender.Controller.controller',...) + * set $view->viewVars['actions'] with $extra + * + * So the whole config it goes into CustomTheme\BakeExtraHelper $config + * and becomes available in all .twig via BakeExtraHelper methods. + */ + +$skipTables = [ 'network_edge_list_tree' ]; +$taskParams = [ + 'default' => [ + 'theme' => 'CustomTheme', + 'no-fixture' => true, + 'no-test' => true, + 'no-rules' => true, + 'index-columns' => 6 + #'components' => 'hello,world', + ], + 'Adherents' => [ 'index-columns' => 7 ], +]; +$controllerActions = [ + 'default' => [ 'index', 'view', 'add', 'edit'], + 'AdherentRoles' => [ 'index', 'add', 'delete' ], + 'AdherentRoleTypes' => [ ], +]; +$templateExtra = [ + 'Adherents' => [ + 'title' => [ + 'custom_code' => <<<'EOT' + "ADT" . $this->_properties['id'] . " - " . ( $this->_properties['raison']?($this->_properties['raison'] . " (" . $this->_properties['nom'] . ")" ):($this->_properties['nom'] . " " . $this->_properties['prenom']) ) +EOT + ], + 'filters' => [ + 'q' => [ + 'mode' => 'like', + 'before' => 'true', + 'after' => 'true', + 'columns' => ['id','nom','nom2','prenom','prenom2','raison','proprio','tel_mobile1','tel_mobile2'], + 'colspan' => 3, + 'hint' => 'Find...', + ], + 'adherent_type_id' => [ + 'mode' => 'value', + 'before' => 'false', + 'after' => 'false', + 'model' => 'AdherentTypes', + 'colspan' => 2, + 'hint' => 'AdherentTypes', + ], + 'ville_id' => [ + 'mode' => 'value', + 'before' => 'false', + 'after' => 'false', + 'model' => 'Villes', + 'colspan' => 2, + 'hint' => 'Villes', + ], + ], + ], +]; + +return compact('skipTables', 'taskParams', 'controllerActions', 'templateExtra'); -- cgit v1.1