2015-02-18 13:39:02 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Deblan\Console\Command;
|
|
|
|
|
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
2015-02-18 22:48:56 +01:00
|
|
|
use Deblan\PowerDNS\Command\Helper\ZoneHelper;
|
|
|
|
use Deblan\PowerDNS\Command\Helper\DomainHelper;
|
2015-02-21 09:59:38 +01:00
|
|
|
use Deblan\PowerDNS\Command\Helper\ValidatorHelper;
|
2015-02-18 13:39:02 +01:00
|
|
|
|
|
|
|
abstract class AbstractCommand extends Command
|
|
|
|
{
|
|
|
|
protected $input;
|
|
|
|
|
|
|
|
protected $output;
|
|
|
|
|
2015-02-21 09:59:38 +01:00
|
|
|
protected $dialog;
|
|
|
|
|
2015-02-18 22:48:56 +01:00
|
|
|
public function getHelper($helper)
|
|
|
|
{
|
|
|
|
if ($helper === 'zone') {
|
|
|
|
return ZoneHelper::getInstance($this->getInput(), $this->getOutput());
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($helper === 'domain') {
|
|
|
|
return DomainHelper::getInstance($this->getInput(), $this->getOutput());
|
|
|
|
}
|
|
|
|
|
2015-02-21 09:59:38 +01:00
|
|
|
if ($helper === 'validator') {
|
|
|
|
return ValidatorHelper::getInstance($this->getInput(), $this->getOutput());
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($helper === 'dialog') {
|
|
|
|
return $this->getHelperSet()->get('dialog');
|
|
|
|
}
|
|
|
|
|
2015-02-18 22:48:56 +01:00
|
|
|
throw new \InvalidArgumentException(sprintf('Invalid helper "%s"', $helper));
|
|
|
|
}
|
|
|
|
|
2015-02-18 13:39:02 +01:00
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
|
|
{
|
|
|
|
$this->setInput($input);
|
|
|
|
$this->setOutput($output);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setInput(InputInterface $input)
|
|
|
|
{
|
|
|
|
$this->input = $input;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getInput()
|
|
|
|
{
|
|
|
|
return $this->input;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setOutput(OutputInterface $output)
|
|
|
|
{
|
|
|
|
$this->output = $output;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getOutput()
|
|
|
|
{
|
|
|
|
return $this->output;
|
|
|
|
}
|
|
|
|
}
|