add new plugin
This commit is contained in:
parent
5c45d62629
commit
a1f5403b32
78
PHPCI/Plugin/SymfonyCommands.php
Normal file
78
PHPCI/Plugin/SymfonyCommands.php
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?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 PHPCI\Plugin;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
42
local_vars.php
Normal file
42
local_vars.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
// Define our APPLICATION_PATH, if not already defined:
|
||||
if (!defined('APPLICATION_PATH')) {
|
||||
define('APPLICATION_PATH', dirname(__FILE__) . '/');
|
||||
define('PHPCI_DIR', APPLICATION_PATH);
|
||||
}
|
||||
|
||||
// Define our PHPCI_URL, if not already defined:
|
||||
if (!defined('PHPCI_URL') && isset($config)) {
|
||||
define('PHPCI_URL', $config->get('phpci.url', '') . '/');
|
||||
}
|
||||
|
||||
// Define PHPCI_BIN_DIR
|
||||
if (!defined('PHPCI_BIN_DIR')) {
|
||||
define('PHPCI_BIN_DIR', PHPCI_DIR . 'vendor/bin/');
|
||||
}
|
||||
|
||||
// Define PHPCI_BUILD_ROOT_DIR
|
||||
if (!defined('PHPCI_BUILD_ROOT_DIR')) {
|
||||
define('PHPCI_BUILD_ROOT_DIR', PHPCI_DIR . 'PHPCI/build/');
|
||||
}
|
||||
|
||||
// Should PHPCI run the Shell plugin?
|
||||
if (!defined('ENABLE_SHELL_PLUGIN')) {
|
||||
define('ENABLE_SHELL_PLUGIN', false);
|
||||
}
|
||||
|
||||
// If this is not already defined, we're not running in the console:
|
||||
if (!defined('PHPCI_IS_CONSOLE')) {
|
||||
define('PHPCI_IS_CONSOLE', false);
|
||||
}
|
||||
|
||||
if (!defined('IS_WIN')) {
|
||||
define('IS_WIN', ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false));
|
||||
}
|
||||
|
||||
// If an environment variable is set defining our config location, use that
|
||||
// otherwise fall back to PHPCI/config.yml.
|
||||
if (!defined('PHPCI_CONFIG_FILE')) {
|
||||
define('PHPCI_CONFIG_FILE', $configFile);
|
||||
}
|
Loading…
Reference in a new issue