Merge pull request #1295 from kszymukowicz/callable_default_stage

Added possibility to use callable when setting 'default_stage'.
This commit is contained in:
Anton Medvedev 2017-07-08 00:24:36 +07:00 committed by GitHub
commit 2e56bfad83
2 changed files with 7 additions and 2 deletions

View File

@ -3,7 +3,8 @@
## master
[v5.1.3...master](https://github.com/deployphp/deployer/compare/v5.1.3...master)
### Added
- Added possibility to use callable when setting 'default_stage'.
## v5.1.3
[v5.1.2...v5.1.3](https://github.com/deployphp/deployer/compare/v5.1.2...v5.1.3)

View File

@ -116,7 +116,11 @@ class Deployer extends Container
return new Task\ScriptManager($c['tasks']);
};
$this['hostSelector'] = function ($c) {
return new Host\HostSelector($c['hosts'], $c['config']['default_stage']);
$defaultStage = $c['config']['default_stage'];
if (is_object($defaultStage) && ($defaultStage instanceof \Closure)) {
$defaultStage = call_user_func($defaultStage);
}
return new Host\HostSelector($c['hosts'], $defaultStage);
};
$this['fail'] = function () {
return new Collection();