2013-10-08 08:45:20 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* PHPCI - Continuous Integration for PHP
|
|
|
|
*
|
2014-05-12 18:26:17 +02:00
|
|
|
* @copyright Copyright 2014, Block 8 Limited.
|
2013-10-08 08:45:20 +02:00
|
|
|
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
|
2014-05-12 18:26:17 +02:00
|
|
|
* @link https://www.phptesting.org/
|
2013-10-08 08:45:20 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace PHPCI\Command;
|
|
|
|
|
2015-02-25 10:36:50 +01:00
|
|
|
use b8\Config;
|
2013-11-02 16:52:55 +01:00
|
|
|
use Monolog\Logger;
|
2014-12-04 16:01:19 +01:00
|
|
|
use PHPCI\Helper\Lang;
|
2013-10-08 08:45:20 +02:00
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate console command - Reads the database and generates models and stores.
|
|
|
|
* @author Dan Cryer <dan@block8.co.uk>
|
|
|
|
* @package PHPCI
|
|
|
|
* @subpackage Console
|
|
|
|
*/
|
|
|
|
class UpdateCommand extends Command
|
|
|
|
{
|
2013-11-02 16:52:55 +01:00
|
|
|
/**
|
|
|
|
* @var \Monolog\Logger
|
|
|
|
*/
|
|
|
|
protected $logger;
|
|
|
|
|
|
|
|
public function __construct(Logger $logger, $name = null)
|
|
|
|
{
|
|
|
|
parent::__construct($name);
|
|
|
|
$this->logger = $logger;
|
|
|
|
}
|
|
|
|
|
2013-10-08 08:45:20 +02:00
|
|
|
protected function configure()
|
|
|
|
{
|
|
|
|
$this
|
|
|
|
->setName('phpci:update')
|
2014-12-04 16:01:19 +01:00
|
|
|
->setDescription(Lang::get('update_phpci'));
|
2013-10-08 08:45:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates Model and Store classes by reading database meta data.
|
|
|
|
*/
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
|
|
{
|
2015-02-12 13:37:56 +01:00
|
|
|
if (!$this->verifyInstalled($output)) {
|
|
|
|
return;
|
|
|
|
}
|
2014-04-10 16:58:26 +02:00
|
|
|
|
2014-12-04 16:01:19 +01:00
|
|
|
$output->write(Lang::get('updating_phpci'));
|
2014-04-10 16:58:26 +02:00
|
|
|
|
2014-05-13 17:15:06 +02:00
|
|
|
shell_exec(PHPCI_DIR . 'vendor/bin/phinx migrate -c "' . PHPCI_DIR . 'phinx.php"');
|
2014-04-10 16:58:26 +02:00
|
|
|
|
2014-12-04 16:01:19 +01:00
|
|
|
$output->writeln('<info>'.Lang::get('ok').'</info>');
|
2014-04-10 16:58:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function verifyInstalled(OutputInterface $output)
|
|
|
|
{
|
2015-02-25 10:36:50 +01:00
|
|
|
$config = Config::getInstance();
|
|
|
|
$phpciUrl = $config->get('phpci.url');
|
2015-02-12 13:37:56 +01:00
|
|
|
|
2015-02-25 10:36:50 +01:00
|
|
|
return !empty($phpciUrl);
|
2013-10-08 08:45:20 +02:00
|
|
|
}
|
|
|
|
}
|