From a1f5403b32faa717f0f22877ae54edd8b71a4d42 Mon Sep 17 00:00:00 2001 From: Alexander Gansky Date: Sat, 19 Dec 2015 20:11:35 +0200 Subject: [PATCH] add new plugin --- PHPCI/Plugin/SymfonyCommands.php | 78 ++++++++++++++++++++++++++++++++ local_vars.php | 42 +++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 PHPCI/Plugin/SymfonyCommands.php create mode 100644 local_vars.php diff --git a/PHPCI/Plugin/SymfonyCommands.php b/PHPCI/Plugin/SymfonyCommands.php new file mode 100644 index 00000000..6fd7d99e --- /dev/null +++ b/PHPCI/Plugin/SymfonyCommands.php @@ -0,0 +1,78 @@ + + * @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); + } + +} diff --git a/local_vars.php b/local_vars.php new file mode 100644 index 00000000..98c07377 --- /dev/null +++ b/local_vars.php @@ -0,0 +1,42 @@ +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); +}