summaryrefslogtreecommitdiff
path: root/fai_gestion/plugins/CustomTheme/src/Shell/BakeShell.php
diff options
context:
space:
mode:
Diffstat (limited to 'fai_gestion/plugins/CustomTheme/src/Shell/BakeShell.php')
-rw-r--r--fai_gestion/plugins/CustomTheme/src/Shell/BakeShell.php29
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;
}