public function __construct(Application $console, Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
parent::__construct();
/******************************
* Console *
******************************/
$this['console'] = function () use($console) {
return $console;
};
$this['input'] = function () use($input) {
return $input;
};
$this['output'] = function () use($output) {
return $output;
};
/******************************
* Config *
******************************/
$this['config'] = function () {
return new Collection();
};
$this->config['ssh_type'] = 'phpseclib';
$this->config['default_stage'] = null;
/******************************
* Core *
******************************/
$this['tasks'] = function () {
return new Task\TaskCollection();
};
$this['servers'] = function () {
return new Server\ServerCollection();
};
$this['environments'] = function () {
return new Server\EnvironmentCollection();
};
$this['scriptManager'] = function ($c) {
return new Task\ScriptManager($c['tasks']);
};
$this['stageStrategy'] = function ($c) {
return new StageStrategy($c['servers'], $c['environments'], $c['config']['default_stage']);
};
$this['onFailure'] = function () {
return new Collection();
};
/******************************
* Logger *
******************************/
$this['log_level'] = Logger::DEBUG;
$this['log_handler'] = function () {
return isset($this->config['log_file']) ? new StreamHandler($this->config['log_file'], $this['log_level']) : new NullHandler($this['log_level']);
};
$this['log'] = function () {
$name = isset($this->config['log_name']) ? $this->config['log_name'] : 'Deployer';
return new Logger($name, [$this['log_handler']]);
};
/******************************
* Init command *
******************************/
$this['init_command'] = function () {
return new InitCommand();
};
self::$instance = $this;
}