-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSymfonyCommands.php
More file actions
79 lines (69 loc) · 1.82 KB
/
SymfonyCommands.php
File metadata and controls
79 lines (69 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* PHPCI - Continuous Integration for PHP. Plugin for using Symfony2 commands.
*
* @package PHPCI\Plugin
* @author Alexander Gansky <a.gansky@mindteam.com.ua>
* @license https://github.com/mindteam/phpci-symfony2-plugin/blob/master/LICENSE
* @link http://mindteam.com.ua
*/
namespace Mindteam\PHPCI\Plugin;
use PHPCI;
use PHPCI\Builder;
use PHPCI\Model\Build;
use Symfony\Component\Yaml\Parser as YamlParser;
use PHPCI\Plugin as BaseInterface;
/**
* Plugin for Symfony2 commands
*/
class SymfonyCommands implements BaseInterface
{
protected $directory;
protected $phpci;
protected $build;
protected $commandList = array();
/**
* Set up the plugin, configure options, etc.
*
* @param Builder $phpci
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
{
$this->phpci = $phpci;
$this->build = $build;
$this->directory = $phpci->buildPath;
if (isset($options['commands'])) {
$this->commandList = $options['commands'];
}
}
/**
* Executes Symfony2 commands
*
* @return boolean plugin work status
*/
public function execute()
{
$success = true;
foreach ($this->commandList as $command) {
if (!$this->runSingleCommand($command)) {
$success = false;
break;
}
}
return $success;
}
/**
* Run one command
*
* @param string $command command for cymfony
*
* @return boolean
*/
public function runSingleCommand($command)
{
$cmd = 'php ' . $this->directory . 'app/console ';
return $this->phpci->executeCommand($cmd . $command, $this->directory);
}
}