Allow to define default options in the tasks (eg: flags)

This commit is contained in:
Andrés Montañez
2017-02-10 23:57:34 -03:00
parent 5f4236c208
commit 83f047aab0
3 changed files with 19 additions and 2 deletions
+3 -1
View File
@@ -29,8 +29,10 @@ abstract class AbstractFileTask extends AbstractTask
protected function getOptions()
{
$mandatory = $this->getParameters();
$defaults = array_keys($this->getDefaults());
$missing = array_diff($mandatory, $defaults);
foreach ($mandatory as $parameter) {
foreach ($missing as $parameter) {
if (!array_key_exists($parameter, $this->options)) {
throw new ErrorException(sprintf('Parameter "%s" is not defined', $parameter));
}
+5
View File
@@ -50,4 +50,9 @@ class ChangeModeTask extends AbstractFileTask
{
return ['file', 'mode', 'flags'];
}
public function getDefaults()
{
return ['flags' => null];
}
}