CakePHP version 2.3.8
If I use public $tasks = array('Email');
and $this->Email->execute();
the output level i.e. Console/cake Test --verbose
will use verbose output in the Email task. But if I load the task on the fly using TaskCollection object it will not. It only uses the default output level of NORMAL.
class TestShell extends AppShell {
public function main() {
$Email = $this->Tasks->load('Email');
$Email->execute();
}
}
class EmailTask extends Shell {
public function execute() {
$this->out('Some debugging output', 1, Shell::VERBOSE);
}
}
How do I set up the TestShell to pass the output level to the EmailTask when it's loaded on the fly?
Update: I tried adding getOptionParser() to Shell and Task so I could use $this->params['verbose']
as per the Cookbook but I get error: Undefined index: verbose.
public function getOptionParser() {
$parser = parent::getOptionParser();
$parser->addOption('verbose', array(
'help' => 'Enable verbose output.',
'boolean' => true
));
return $parser;
}
Update with sort of solution
I can pass the params manually to the Task like so:
public function main() {
$Email = $this->Tasks->load('Email');
$Email->params =& $this->params;
$Email->execute();
}
But shouldn't TaskCollection do that for me?