* @package PHPCI
* @subpackage Console
*/
class UpdateCommand extends Command
{
/**
* @var \Monolog\Logger
*/
protected $logger;
public function __construct(Logger $logger, $name = null)
{
parent::__construct($name);
$this->logger = $logger;
}
protected function configure()
{
$this
->setName('phpci:update')
->setDescription(Lang::get('update_phpci'));
}
/**
* Generates Model and Store classes by reading database meta data.
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!$this->verifyInstalled($output)) {
return;
}
$output->write(Lang::get('updating_phpci'));
shell_exec(PHPCI_DIR . 'vendor/bin/phinx migrate -c "' . PHPCI_DIR . 'phinx.php"');
$output->writeln(''.Lang::get('ok').'');
}
protected function verifyInstalled(OutputInterface $output)
{
if (!file_exists(PHPCI_DIR . 'PHPCI/config.yml')) {
$output->writeln(''.Lang::get('not_installed').'');
$output->writeln(''.Lang::get('install_instead').'');
return false;
}
$content = file_get_contents(PHPCI_DIR . 'PHPCI/config.yml');
if (empty($content)) {
$output->writeln(''.Lang::get('not_installed').'');
$output->writeln(''.Lang::get('install_instead').'');
return false;
}
return true;
}
}