Fixed namespaces (PHPCI -> PHPCensor)
This commit is contained in:
parent
60d74b0b44
commit
60a2b7282a
238 changed files with 1014 additions and 863 deletions
85
src/PHPCensor/Command/CreateBuildCommand.php
Normal file
85
src/PHPCensor/Command/CreateBuildCommand.php
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPCI - Continuous Integration for PHP
|
||||
*
|
||||
* @copyright Copyright 2014, Block 8 Limited.
|
||||
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
|
||||
* @link https://www.phptesting.org/
|
||||
*/
|
||||
|
||||
namespace PHPCensor\Command;
|
||||
|
||||
use PHPCensor\Helper\Lang;
|
||||
use PHPCensor\Service\BuildService;
|
||||
use PHPCensor\Store\ProjectStore;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Create build command - creates a build for a project
|
||||
* @author Jérémy DECOOL (@jdecool)
|
||||
* @package PHPCI
|
||||
* @subpackage Console
|
||||
*/
|
||||
class CreateBuildCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var ProjectStore
|
||||
*/
|
||||
protected $projectStore;
|
||||
|
||||
/**
|
||||
* @var BuildService
|
||||
*/
|
||||
protected $buildService;
|
||||
|
||||
/**
|
||||
* @param ProjectStore $projectStore
|
||||
*/
|
||||
public function __construct(ProjectStore $projectStore, BuildService $buildService)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->projectStore = $projectStore;
|
||||
$this->buildService = $buildService;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('phpci:create-build')
|
||||
->setDescription(Lang::get('create_build_project'))
|
||||
->addArgument('projectId', InputArgument::REQUIRED, Lang::get('project_id_argument'))
|
||||
->addOption('commit', null, InputOption::VALUE_OPTIONAL, Lang::get('commit_id_option'))
|
||||
->addOption('branch', null, InputOption::VALUE_OPTIONAL, Lang::get('branch_name_option'));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$projectId = $input->getArgument('projectId');
|
||||
$commitId = $input->getOption('commit');
|
||||
$branch = $input->getOption('branch');
|
||||
|
||||
$project = $this->projectStore->getById($projectId);
|
||||
if (empty($project)) {
|
||||
throw new \InvalidArgumentException('Project does not exist: ' . $projectId);
|
||||
}
|
||||
|
||||
try {
|
||||
$this->buildService->createBuild($project, $commitId, $branch);
|
||||
$output->writeln(Lang::get('build_created'));
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln(sprintf('<error>%s</error>', Lang::get('failed')));
|
||||
$output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue