diff options
author | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2018-07-19 00:27:58 +0200 |
---|---|---|
committer | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2018-07-19 00:27:58 +0200 |
commit | 76ab63096a25f5bf7b9d076cdc9ab3fc5218d216 (patch) | |
tree | 60532cca38489cfd6152fa2736a5765bbe03dd61 /fai_gestion/plugins | |
parent | 7de45a8e4b595856de2f0af78b13e4d2efc5e716 (diff) | |
download | chd_gestion-76ab63096a25f5bf7b9d076cdc9ab3fc5218d216.zip chd_gestion-76ab63096a25f5bf7b9d076cdc9ab3fc5218d216.tar.gz chd_gestion-76ab63096a25f5bf7b9d076cdc9ab3fc5218d216.tar.bz2 |
bake all : skip some models and actions, via configuration
Diffstat (limited to 'fai_gestion/plugins')
-rw-r--r-- | fai_gestion/plugins/CustomTheme/src/Shell/BakeShell.php | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/fai_gestion/plugins/CustomTheme/src/Shell/BakeShell.php b/fai_gestion/plugins/CustomTheme/src/Shell/BakeShell.php index 6734006..0e42919 100644 --- a/fai_gestion/plugins/CustomTheme/src/Shell/BakeShell.php +++ b/fai_gestion/plugins/CustomTheme/src/Shell/BakeShell.php @@ -28,14 +28,22 @@ class BakeShell extends BaseShell { /** * Assign $this->connection to the active task if a connection param is set. + * Add values to $this->Model->skipTables if config/bake_extra.php define it * * @return void */ public function startup() { parent::startup(); - } + $this->extra = include(ROOT . DS . 'config' . DS . 'bake_extra.php'); + /* Allow skipping more tables than bake' ModelTask default */ + if ( array_key_exists('skipTables', $this->extra) ) { + $skipTables = $this->extra['skipTables']; + array_walk($skipTables, 'Cake\Utility\Inflector::tableize'); + $this->Model->skipTables = array_merge($this->Model->skipTables, $skipTables); + } + } /** * Quickly bake the MVC * @@ -44,7 +52,7 @@ class BakeShell extends BaseShell { */ public function all($name = null) { - $this->out('Bake All'); + $this->out('CustomTheme Bake All'); $this->hr(); if (!empty($this->params['connection'])) { @@ -73,13 +81,28 @@ class BakeShell extends BaseShell { foreach (['Model', 'Controller', 'Template'] as $task) { $filteredTables->each(function ($tableName) use ($task) { $tableName = $this->_camelize($tableName); + + /* Allow feedding some parameters to each *Task run */ + if ( array_key_exists('taskParams', $this->extra) ){ + $extra = $this->extra['taskParams']; + /* Cake\Console\Shell __get($name) for lazy building of tasks do: + * $this->{$task}->params =& $this->params; + * We want different params at each use of tasks, so reset it + */ + $task_params = $this->params; + if ( array_key_exists('default', $extra) ) + $task_params = array_merge($task_params, $extra['default']); + if ( array_key_exists($tableName, $extra) ) + $task_params = array_merge($task_params, $extra[$tableName]); + $this->{$task}->params = $task_params; + } $this->{$task}->connection = $this->connection; $this->{$task}->interactive = $this->interactive; $this->{$task}->main($tableName); }); } - $this->out('<success>Bake All complete.</success>', 1, Shell::QUIET); + $this->out('<success>CustomTheme Bake All complete.</success>', 1, Shell::QUIET); return true; } |