Merge branch 'feature-cleanup'
This commit is contained in:
commit
58798fb2f9
|
@ -15,6 +15,8 @@ test:
|
|||
|
||||
php_mess_detector:
|
||||
allow_failures: true
|
||||
rules:
|
||||
- phpmd.xml
|
||||
|
||||
php_code_sniffer:
|
||||
standard: PSR2
|
||||
|
|
32
phpmd.xml
Normal file
32
phpmd.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0"?>
|
||||
<ruleset name="PHP Censor ruleset" xmlns="http://pmd.sf.net/ruleset/1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
|
||||
xsi:noNamespaceSchemaLocation=" http://pmd.sf.net/ruleset_xml_schema.xsd">
|
||||
|
||||
<description>
|
||||
PHP Censor ruleset
|
||||
</description>
|
||||
|
||||
<rule ref="rulesets/cleancode.xml" />
|
||||
<rule ref="rulesets/codesize.xml" />
|
||||
<rule ref="rulesets/controversial.xml" />
|
||||
<rule ref="rulesets/design.xml" />
|
||||
<rule ref="rulesets/unusedcode.xml" />
|
||||
|
||||
<rule ref="rulesets/naming.xml">
|
||||
<exclude name="ShortVariable"/>
|
||||
<exclude name="ShortMethodName"/>
|
||||
</rule>
|
||||
|
||||
<rule ref="rulesets/naming.xml/ShortVariable">
|
||||
<properties>
|
||||
<property name="exceptions" value="db,dn,id,i,j" />
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="rulesets/naming.xml/ShortMethodName">
|
||||
<properties>
|
||||
<property name="exceptions" value="up" />
|
||||
</properties>
|
||||
</rule>
|
||||
</ruleset>
|
|
@ -3,9 +3,9 @@
|
|||
namespace b8;
|
||||
|
||||
use b8\Exception\HttpException\NotFoundException;
|
||||
use b8\Http;
|
||||
use b8\Http\Response;
|
||||
use b8\Http\Request;
|
||||
use b8\Http\Router;
|
||||
|
||||
class Application
|
||||
{
|
||||
|
@ -34,23 +34,28 @@ class Application
|
|||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var Router
|
||||
*/
|
||||
protected $router;
|
||||
|
||||
/**
|
||||
* @param Config $config
|
||||
*
|
||||
* @param Request|null $request
|
||||
*/
|
||||
public function __construct(Config $config, Http\Request $request = null)
|
||||
public function __construct(Config $config, Request $request = null)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->response = new Http\Response();
|
||||
$this->response = new Response();
|
||||
|
||||
if (!is_null($request)) {
|
||||
$this->request = $request;
|
||||
} else {
|
||||
$this->request = new Http\Request();
|
||||
$this->request = new Request();
|
||||
}
|
||||
|
||||
$this->router = new Http\Router($this, $this->request, $this->config);
|
||||
$this->router = new Router($this, $this->request, $this->config);
|
||||
|
||||
if (method_exists($this, 'init')) {
|
||||
$this->init();
|
||||
|
@ -92,9 +97,10 @@ class Application
|
|||
public function getController()
|
||||
{
|
||||
if (empty($this->controller)) {
|
||||
$controllerClass = $this->getControllerClass($this->route);
|
||||
$controllerClass = $this->getControllerClass($this->route);
|
||||
$this->controller = $this->loadController($controllerClass);
|
||||
}
|
||||
|
||||
return $this->controller;
|
||||
}
|
||||
|
||||
|
@ -105,8 +111,10 @@ class Application
|
|||
*/
|
||||
protected function loadController($class)
|
||||
{
|
||||
/** @var Controller $controller */
|
||||
$controller = new $class($this->config, $this->request, $this->response);
|
||||
$controller->init();
|
||||
|
||||
return $controller;
|
||||
}
|
||||
|
||||
|
@ -127,8 +135,9 @@ class Application
|
|||
*/
|
||||
protected function getControllerClass($route)
|
||||
{
|
||||
$namespace = $this->toPhpName($route['namespace']);
|
||||
$namespace = $this->toPhpName($route['namespace']);
|
||||
$controller = $this->toPhpName($route['controller']);
|
||||
|
||||
return $this->config->get('b8.app.namespace') . '\\' . $namespace . '\\' . $controller . 'Controller';
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ class Config
|
|||
{
|
||||
// Path to a YAML file.
|
||||
$parser = new YamlParser();
|
||||
$yaml = file_get_contents($yamlFile);
|
||||
$yaml = file_get_contents($yamlFile);
|
||||
$config = (array)$parser->parse($yaml);
|
||||
|
||||
if (empty($config)) {
|
||||
|
@ -75,7 +75,7 @@ class Config
|
|||
$keyParts = explode('.', $key);
|
||||
$selected = $this->config;
|
||||
|
||||
$i = -1;
|
||||
$i = -1;
|
||||
$last_part = count($keyParts) - 1;
|
||||
while ($part = array_shift($keyParts)) {
|
||||
$i++;
|
||||
|
@ -180,6 +180,7 @@ class Config
|
|||
$source = $target;
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($target as $target_key => $target_value) {
|
||||
if (isset($source[$target_key])) {
|
||||
if (!is_array($source[$target_key]) && !is_array($target_value)) {
|
||||
|
@ -188,7 +189,6 @@ class Config
|
|||
} elseif (is_array($source[$target_key]) && is_array($target_value)) {
|
||||
// Both are arrays, deep merge them
|
||||
self::deepMerge($source[$target_key], $target_value);
|
||||
|
||||
} elseif (is_array($source[$target_key])) {
|
||||
// Source is the array, push target value
|
||||
$source[$target_key][] = $target_value;
|
||||
|
|
|
@ -111,6 +111,7 @@ class Database extends \PDO
|
|||
}
|
||||
|
||||
self::$lastUsed[$type] = time();
|
||||
|
||||
return self::$connections[$type];
|
||||
}
|
||||
|
||||
|
@ -134,7 +135,7 @@ class Database extends \PDO
|
|||
} elseif ('pgsql' === self::$details['type']) {
|
||||
$quote = '"';
|
||||
}
|
||||
|
||||
|
||||
$statement = preg_replace('/{{(.*?)}}/', ($quote . '\1' . $quote), $statement);
|
||||
|
||||
return parent::prepare($statement, $driver_options);
|
||||
|
|
|
@ -9,19 +9,19 @@ class Form extends FieldSet
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_action = '';
|
||||
protected $action = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_method = 'POST';
|
||||
protected $method = 'POST';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAction()
|
||||
{
|
||||
return $this->_action;
|
||||
return $this->action;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@ class Form extends FieldSet
|
|||
*/
|
||||
public function setAction($action)
|
||||
{
|
||||
$this->_action = $action;
|
||||
$this->action = $action;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@ class Form extends FieldSet
|
|||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return $this->_method;
|
||||
return $this->method;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ class Form extends FieldSet
|
|||
*/
|
||||
public function setMethod($method)
|
||||
{
|
||||
$this->_method = $method;
|
||||
$this->method = $method;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,32 +10,32 @@ abstract class Element
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_name;
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_id;
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_label;
|
||||
protected $label;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_css;
|
||||
protected $class;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_ccss;
|
||||
protected $containerClass;
|
||||
|
||||
/**
|
||||
* @var Element
|
||||
*/
|
||||
protected $_parent;
|
||||
protected $parent;
|
||||
|
||||
/**
|
||||
* @param string|null $name
|
||||
|
@ -52,7 +52,7 @@ abstract class Element
|
|||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->_name;
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,7 +62,8 @@ abstract class Element
|
|||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->_name = strtolower(preg_replace('/([^a-zA-Z0-9_\-%])/', '', $name));
|
||||
$this->name = strtolower(preg_replace('/([^a-zA-Z0-9_\-%])/', '', $name));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -71,7 +72,9 @@ abstract class Element
|
|||
*/
|
||||
public function getId()
|
||||
{
|
||||
return !$this->_id ? 'element-' . $this->_name : $this->_id;
|
||||
return !$this->id
|
||||
? ('element-' . $this->name)
|
||||
: $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,7 +84,8 @@ abstract class Element
|
|||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->_id = $id;
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -90,7 +94,7 @@ abstract class Element
|
|||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->_label;
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,7 +104,8 @@ abstract class Element
|
|||
*/
|
||||
public function setLabel($label)
|
||||
{
|
||||
$this->_label = $label;
|
||||
$this->label = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -109,7 +114,7 @@ abstract class Element
|
|||
*/
|
||||
public function getClass()
|
||||
{
|
||||
return $this->_css;
|
||||
return $this->class;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -119,7 +124,8 @@ abstract class Element
|
|||
*/
|
||||
public function setClass($class)
|
||||
{
|
||||
$this->_css = $class;
|
||||
$this->class = $class;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -128,7 +134,7 @@ abstract class Element
|
|||
*/
|
||||
public function getContainerClass()
|
||||
{
|
||||
return $this->_ccss;
|
||||
return $this->containerClass;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -138,7 +144,8 @@ abstract class Element
|
|||
*/
|
||||
public function setContainerClass($class)
|
||||
{
|
||||
$this->_ccss = $class;
|
||||
$this->containerClass = $class;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -149,7 +156,8 @@ abstract class Element
|
|||
*/
|
||||
public function setParent(Element $parent)
|
||||
{
|
||||
$this->_parent = $parent;
|
||||
$this->parent = $parent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -173,12 +181,12 @@ abstract class Element
|
|||
$view = new View($viewFile, B8_PATH . 'Form/View/');
|
||||
}
|
||||
|
||||
$view->name = $this->getName();
|
||||
$view->id = $this->getId();
|
||||
$view->label = $this->getLabel();
|
||||
$view->css = $this->getClass();
|
||||
$view->ccss = $this->getContainerClass();
|
||||
$view->parent = $this->_parent;
|
||||
$view->name = $this->getName();
|
||||
$view->id = $this->getId();
|
||||
$view->label = $this->getLabel();
|
||||
$view->class = $this->getClass();
|
||||
$view->containerClass = $this->getContainerClass();
|
||||
$view->parent = $this->parent;
|
||||
|
||||
$this->onPreRender($view);
|
||||
|
||||
|
|
|
@ -10,19 +10,19 @@ class Checkbox extends Input
|
|||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_checked;
|
||||
protected $checked;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
protected $_checkedValue;
|
||||
protected $checkedValue;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCheckedValue()
|
||||
{
|
||||
return $this->_checkedValue;
|
||||
return $this->checkedValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ class Checkbox extends Input
|
|||
*/
|
||||
public function setCheckedValue($value)
|
||||
{
|
||||
$this->_checkedValue = $value;
|
||||
$this->checkedValue = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,19 +39,19 @@ class Checkbox extends Input
|
|||
public function setValue($value)
|
||||
{
|
||||
if (is_bool($value) && $value === true) {
|
||||
$this->_value = $this->getCheckedValue();
|
||||
$this->_checked = true;
|
||||
$this->value = $this->getCheckedValue();
|
||||
$this->checked = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($value == $this->getCheckedValue()) {
|
||||
$this->_value = $this->getCheckedValue();
|
||||
$this->_checked = true;
|
||||
$this->value = $this->getCheckedValue();
|
||||
$this->checked = true;
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_value = $value;
|
||||
$this->_checked = false;
|
||||
$this->value = $value;
|
||||
$this->checked = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,6 +62,6 @@ class Checkbox extends Input
|
|||
parent::onPreRender($view);
|
||||
|
||||
$view->checkedValue = $this->getCheckedValue();
|
||||
$view->checked = $this->_checked;
|
||||
$view->checked = $this->checked;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,14 +9,14 @@ class Csrf extends Hidden
|
|||
/**
|
||||
* @var integer
|
||||
*/
|
||||
protected $_rows = 4;
|
||||
protected $rows = 4;
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function validate()
|
||||
{
|
||||
if ($this->_value != $_COOKIE[$this->getName()]) {
|
||||
if ($this->value != $_COOKIE[$this->getName()]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,14 +10,14 @@ class Select extends Input
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_options = [];
|
||||
protected $options = [];
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
$this->_options = $options;
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,6 +27,6 @@ class Select extends Input
|
|||
{
|
||||
parent::onPreRender($view);
|
||||
|
||||
$view->options = $this->_options;
|
||||
$view->options = $this->options;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ class Submit extends Button
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_value = 'Submit';
|
||||
protected $value = 'Submit';
|
||||
|
||||
/**
|
||||
* @param string $viewFile
|
||||
|
|
|
@ -9,14 +9,14 @@ class TextArea extends Text
|
|||
/**
|
||||
* @var integer
|
||||
*/
|
||||
protected $_rows = 4;
|
||||
protected $rows = 4;
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
public function getRows()
|
||||
{
|
||||
return $this->_rows;
|
||||
return $this->rows;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,7 +24,7 @@ class TextArea extends Text
|
|||
*/
|
||||
public function setRows($rows)
|
||||
{
|
||||
$this->_rows = $rows;
|
||||
$this->rows = $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,7 +9,7 @@ class FieldSet extends Element
|
|||
/**
|
||||
* @var Element[]
|
||||
*/
|
||||
protected $_children = [];
|
||||
protected $children = [];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
|
@ -17,7 +17,7 @@ class FieldSet extends Element
|
|||
public function getValues()
|
||||
{
|
||||
$rtn = [];
|
||||
foreach ($this->_children as $field) {
|
||||
foreach ($this->children as $field) {
|
||||
if ($field instanceof FieldSet) {
|
||||
$fieldName = $field->getName();
|
||||
|
||||
|
@ -41,7 +41,7 @@ class FieldSet extends Element
|
|||
*/
|
||||
public function setValues(array $values)
|
||||
{
|
||||
foreach ($this->_children as $field) {
|
||||
foreach ($this->children as $field) {
|
||||
if ($field instanceof FieldSet) {
|
||||
$fieldName = $field->getName();
|
||||
|
||||
|
@ -65,7 +65,7 @@ class FieldSet extends Element
|
|||
*/
|
||||
public function addField(Element $field)
|
||||
{
|
||||
$this->_children[$field->getName()] = $field;
|
||||
$this->children[$field->getName()] = $field;
|
||||
$field->setParent($this);
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ class FieldSet extends Element
|
|||
{
|
||||
$rtn = true;
|
||||
|
||||
foreach ($this->_children as $child) {
|
||||
foreach ($this->children as $child) {
|
||||
if (!$child->validate()) {
|
||||
$rtn = false;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ class FieldSet extends Element
|
|||
protected function onPreRender(View &$view)
|
||||
{
|
||||
$rendered = [];
|
||||
foreach ($this->_children as $child) {
|
||||
foreach ($this->children as $child) {
|
||||
$rendered[] = $child->render();
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ class FieldSet extends Element
|
|||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
return $this->_children;
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,6 +113,6 @@ class FieldSet extends Element
|
|||
*/
|
||||
public function getChild($fieldName)
|
||||
{
|
||||
return $this->_children[$fieldName];
|
||||
return $this->children[$fieldName];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class Input extends Element
|
|||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
protected $_value;
|
||||
protected $value;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
@ -58,7 +58,7 @@ class Input extends Element
|
|||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->_value;
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,7 +68,7 @@ class Input extends Element
|
|||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->_value = $value;
|
||||
$this->value = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -140,12 +140,12 @@ class Input extends Element
|
|||
*/
|
||||
public function validate()
|
||||
{
|
||||
if ($this->getRequired() && empty($this->_value)) {
|
||||
if ($this->getRequired() && empty($this->value)) {
|
||||
$this->_error = $this->getLabel() . ' is required.';
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->getPattern() && !preg_match('/' . $this->getPattern() . '/', $this->_value)) {
|
||||
if ($this->getPattern() && !preg_match('/' . $this->getPattern() . '/', $this->value)) {
|
||||
$this->_error = 'Invalid value entered.';
|
||||
|
||||
return false;
|
||||
|
@ -155,7 +155,7 @@ class Input extends Element
|
|||
|
||||
if (is_callable($validator)) {
|
||||
try {
|
||||
call_user_func_array($validator, [$this->_value]);
|
||||
call_user_func_array($validator, [$this->value]);
|
||||
} catch (\Exception $ex) {
|
||||
$this->_error = $ex->getMessage();
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
<input class="btn <?= $css; ?>" type="<?= $type; ?>" value="<?= $value; ?>">
|
||||
<input class="btn <?= $class; ?>" type="<?= $type; ?>" value="<?= $value; ?>">
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php if (!($parent instanceof \b8\Form\Element\CheckboxGroup)): ?>
|
||||
<div class="control-group <?= $ccss ?> <?= (isset($error) ? 'error' : ''); ?>">
|
||||
<div class="control-group <?= $containerClass ?> <?= (isset($error) ? 'error' : ''); ?>">
|
||||
<div class="controls">
|
||||
<div class="checkbox">
|
||||
<?php endif; ?>
|
||||
<label class="checkbox <?= $css; ?>" for="<?= $id ?>">
|
||||
<label class="checkbox <?= $class; ?>" for="<?= $id ?>">
|
||||
<input type="checkbox" id="<?= $id; ?>" name="<?= $name; ?>"
|
||||
value="<?= $checkedValue; ?>"
|
||||
<?= ($checked ? 'checked' : ''); ?> <?= $required ? 'required' : '' ?>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="control-group <?= $css; ?>">
|
||||
<div class="control-group <?= $class; ?>">
|
||||
<?php if ($label): ?>
|
||||
<label class="control-label"><?= $label; ?></label>
|
||||
<?php endif; ?>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="control-group <?= $css; ?>">
|
||||
<div class="control-group <?= $class; ?>">
|
||||
<?php foreach ($children as $field): ?>
|
||||
<?= $field; ?>
|
||||
<?php endforeach; ?>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<fieldset class="row <?= $css; ?>">
|
||||
<fieldset class="row <?= $class; ?>">
|
||||
<?php if ($label): ?>
|
||||
<legend><?= $label; ?></legend>
|
||||
<?php endif; ?>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<form id="<?= $id; ?>" class="<?= $css; ?>" action="<?= $action; ?>" method="<?= $method; ?>">
|
||||
<form id="<?= $id; ?>" class="<?= $class; ?>" action="<?= $action; ?>" method="<?= $method; ?>">
|
||||
<?php foreach ($children as $field): ?>
|
||||
<?= $field; ?>
|
||||
<?php endforeach; ?>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<div id="<?= $id; ?>" class="control-group <?= $ccss; ?>">
|
||||
<div id="<?= $id; ?>" class="control-group <?= $containerClass; ?>">
|
||||
<?php if ($label): ?>
|
||||
<label class="control-label"><?= $label; ?></label>
|
||||
<?php endif; ?>
|
||||
<div class="controls">
|
||||
<?php foreach ($options as $val => $lbl): ?>
|
||||
<label class="radio" for="radio-<?= $id; ?>-<?= $val; ?>">
|
||||
<input type="radio" id="radio-<?= $id; ?>-<?= $val; ?>" class="<?= $css; ?>"
|
||||
<input type="radio" id="radio-<?= $id; ?>-<?= $val; ?>" class="<?= $class; ?>"
|
||||
name="<?= $name; ?>"
|
||||
value="<?= $val; ?>"
|
||||
<?= ($value == $val) ? ' checked="checked"' : ''; ?> <?= $required ? 'required' : '' ?>
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<div class="control-group <?= $ccss; ?>">
|
||||
<div class="control-group <?= $containerClass; ?>">
|
||||
<?php if ($label): ?>
|
||||
<label class="control-label" for="<?= $id ?>"><?= $label; ?></label>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="controls">
|
||||
<select id="<?= $id; ?>" class="<?= $css; ?>" name="<?= $name; ?>">
|
||||
<select id="<?= $id; ?>" class="<?= $class; ?>" name="<?= $name; ?>">
|
||||
<?php foreach ($options as $val => $lbl): ?>
|
||||
<option
|
||||
value="<?= $val; ?>" <?= ($value == $val) ? ' selected="selected"' : ''; ?>
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<div class="control-group <?= $ccss; ?> <?= (isset($error) ? 'error' : ''); ?>">
|
||||
<div class="control-group <?= $containerClass; ?> <?= (isset($error) ? 'error' : ''); ?>">
|
||||
<?php if ($label): ?>
|
||||
<label class="control-label" for="<?= $id ?>"><?= $label; ?></label>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="controls">
|
||||
<input id="<?= $id; ?>" type="<?= $type; ?>" class="<?= $css; ?>"
|
||||
<input id="<?= $id; ?>" type="<?= $type; ?>" class="<?= $class; ?>"
|
||||
name="<?= $name; ?>"
|
||||
<?= isset($value) ? ' value="' . $value . '"' : '' ?>
|
||||
<?= isset($pattern) ? ' pattern="' . $pattern . '"' : '' ?>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<div class="control-group <?= $ccss; ?> <?= (isset($error) ? 'error' : ''); ?>">
|
||||
<div class="control-group <?= $containerClass; ?> <?= (isset($error) ? 'error' : ''); ?>">
|
||||
<?php if ($label): ?>
|
||||
<label class="control-label" for="<?= $id ?>"><?= $label; ?></label>
|
||||
<?php endif; ?>
|
||||
<div class="controls">
|
||||
<textarea rows="<?= $rows; ?>" id="<?= $id; ?>" class="<?= $css; ?>"
|
||||
<textarea rows="<?= $rows; ?>" id="<?= $id; ?>" class="<?= $class; ?>"
|
||||
name="<?= $name; ?>" <?= $required ? ' required' : '' ?>><?= isset($value) ? $value : '' ?></textarea>
|
||||
|
||||
<?php if (isset($error)): ?>
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
namespace b8\Http;
|
||||
|
||||
use b8\Application, b8\Config;
|
||||
use b8\Application;
|
||||
use b8\Config;
|
||||
|
||||
class Router
|
||||
{
|
||||
|
|
|
@ -14,6 +14,9 @@ class Model
|
|||
protected $tableName;
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* @param array $initialData
|
||||
*/
|
||||
public function __construct($initialData = [])
|
||||
{
|
||||
if (is_array($initialData)) {
|
||||
|
@ -23,11 +26,20 @@ class Model
|
|||
$this->cache = Cache::getCache(Cache::TYPE_REQUEST);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTableName()
|
||||
{
|
||||
return $this->tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $depth
|
||||
* @param integer $currentDepth
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($depth = 2, $currentDepth = 0)
|
||||
{
|
||||
if (isset(static::$sleepable) && is_array(static::$sleepable) && count(static::$sleepable)) {
|
||||
|
@ -44,6 +56,13 @@ class Model
|
|||
return $rtn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $property
|
||||
* @param integer $currentDepth
|
||||
* @param integer $depth
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function propertyToArray($property, $currentDepth, $depth)
|
||||
{
|
||||
$rtn = null;
|
||||
|
@ -60,6 +79,13 @@ class Model
|
|||
return $rtn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @param integer $currentDepth
|
||||
* @param integer $depth
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function valueToArray($value, $currentDepth, $depth)
|
||||
{
|
||||
$rtn = null;
|
||||
|
@ -84,16 +110,25 @@ class Model
|
|||
return $rtn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDataArray()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getModified()
|
||||
{
|
||||
return $this->modified;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $values
|
||||
*/
|
||||
public function setValues(array $values)
|
||||
{
|
||||
foreach ($values as $key => $value) {
|
||||
|
@ -113,11 +148,20 @@ class Model
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
*/
|
||||
protected function setModified($column)
|
||||
{
|
||||
$this->modified[$column] = $column;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*
|
||||
* @throws HttpException\ValidationException
|
||||
*/
|
||||
protected function validateString($name, $value)
|
||||
{
|
||||
if (!is_string($value) && !is_null($value)) {
|
||||
|
@ -125,6 +169,12 @@ class Model
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*
|
||||
* @throws HttpException\ValidationException
|
||||
*/
|
||||
protected function validateInt($name, &$value)
|
||||
{
|
||||
if (is_bool($value)) {
|
||||
|
@ -140,6 +190,12 @@ class Model
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*
|
||||
* @throws HttpException\ValidationException
|
||||
*/
|
||||
protected function validateFloat($name, &$value)
|
||||
{
|
||||
if (!is_numeric($value) && !is_null($value)) {
|
||||
|
@ -151,6 +207,12 @@ class Model
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*
|
||||
* @throws HttpException\ValidationException
|
||||
*/
|
||||
protected function validateDate($name, &$value)
|
||||
{
|
||||
if (is_string($value)) {
|
||||
|
@ -164,6 +226,12 @@ class Model
|
|||
$value = empty($value) ? null : $value->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*
|
||||
* @throws HttpException\ValidationException
|
||||
*/
|
||||
protected function validateNotNull($name, $value)
|
||||
{
|
||||
if (is_null($value)) {
|
||||
|
@ -171,6 +239,11 @@ class Model
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
if (array_key_exists($key, $this->getters)) {
|
||||
|
@ -181,6 +254,12 @@ class Model
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __set($key, $value)
|
||||
{
|
||||
if (array_key_exists($key, $this->setters)) {
|
||||
|
|
|
@ -4,8 +4,8 @@ namespace b8;
|
|||
|
||||
class View
|
||||
{
|
||||
protected $_vars = [];
|
||||
protected static $_helpers = [];
|
||||
protected $vars = [];
|
||||
protected static $helpers = [];
|
||||
protected static $extension = 'phtml';
|
||||
|
||||
public function __construct($file, $path = null)
|
||||
|
@ -36,22 +36,22 @@ class View
|
|||
|
||||
public function __isset($var)
|
||||
{
|
||||
return isset($this->_vars[$var]);
|
||||
return isset($this->vars[$var]);
|
||||
}
|
||||
|
||||
public function __get($var)
|
||||
{
|
||||
return $this->_vars[$var];
|
||||
return $this->vars[$var];
|
||||
}
|
||||
|
||||
public function __set($var, $val)
|
||||
{
|
||||
$this->_vars[$var] = $val;
|
||||
$this->vars[$var] = $val;
|
||||
}
|
||||
|
||||
public function __call($method, $params = [])
|
||||
{
|
||||
if (!isset(self::$_helpers[$method])) {
|
||||
if (!isset(self::$helpers[$method])) {
|
||||
$class = '\\' . Config::getInstance()->get('b8.app.namespace') . '\\Helper\\' . $method;
|
||||
|
||||
if (!class_exists($class)) {
|
||||
|
@ -62,15 +62,15 @@ class View
|
|||
throw new \Exception('Helper class does not exist: ' . $class);
|
||||
}
|
||||
|
||||
self::$_helpers[$method] = new $class();
|
||||
self::$helpers[$method] = new $class();
|
||||
}
|
||||
|
||||
return self::$_helpers[$method];
|
||||
return self::$helpers[$method];
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
extract($this->_vars);
|
||||
extract($this->vars);
|
||||
|
||||
ob_start();
|
||||
require($this->viewFile);
|
||||
|
|
|
@ -7,6 +7,7 @@ use b8\View;
|
|||
class Template extends View
|
||||
{
|
||||
public static $templateFunctions = [];
|
||||
|
||||
protected static $extension = 'html';
|
||||
|
||||
public function __construct($viewCode)
|
||||
|
@ -222,10 +223,19 @@ class Template extends View
|
|||
{
|
||||
$matches = [];
|
||||
|
||||
if (preg_match('/([a-zA-Z0-9_\-\(\):\s.\"]+)\s+?([\!\=\<\>]+)?\s+?([a-zA-Z0-9\(\)_\-:\s.\"]+)?/', $condition,
|
||||
$matches)) {
|
||||
$left = is_numeric($matches[1]) ? intval($matches[1]) : $this->processVariableName($matches[1]);
|
||||
$right = is_numeric($matches[3]) ? intval($matches[3]) : $this->processVariableName($matches[3]);
|
||||
if (preg_match(
|
||||
'/([a-zA-Z0-9_\-\(\):\s.\"]+)\s+?([\!\=\<\>]+)?\s+?([a-zA-Z0-9\(\)_\-:\s.\"]+)?/',
|
||||
$condition,
|
||||
$matches
|
||||
)) {
|
||||
$left = is_numeric($matches[1])
|
||||
? intval($matches[1])
|
||||
: $this->processVariableName($matches[1]);
|
||||
|
||||
$right = is_numeric($matches[3])
|
||||
? intval($matches[3])
|
||||
: $this->processVariableName($matches[3]);
|
||||
|
||||
$operator = $matches[2];
|
||||
|
||||
switch ($operator) {
|
||||
|
@ -374,7 +384,6 @@ class Template extends View
|
|||
{
|
||||
// Case one - Test for function calls:
|
||||
if (substr($varName, 0, 1) == '(' && substr($varName, -1) == ')') {
|
||||
|
||||
$functionCall = substr($varName, 1, -1);
|
||||
$parts = explode(' ', $functionCall, 2);
|
||||
$functionName = $parts[0];
|
||||
|
@ -411,7 +420,7 @@ class Template extends View
|
|||
$thisPart = array_shift($varPart);
|
||||
|
||||
|
||||
if (!array_key_exists($thisPart, $this->_vars)) {
|
||||
if (!array_key_exists($thisPart, $this->vars)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -469,7 +478,8 @@ class Template extends View
|
|||
{
|
||||
if (array_key_exists($function, self::$templateFunctions)) {
|
||||
$handler = self::$templateFunctions[$function];
|
||||
$args = $this->processFunctionArguments($args);
|
||||
$args = $this->processFunctionArguments($args);
|
||||
|
||||
return $handler($args, $this);
|
||||
}
|
||||
|
||||
|
@ -478,15 +488,13 @@ class Template extends View
|
|||
|
||||
protected function processFunctionArguments($args)
|
||||
{
|
||||
$rtn = [];
|
||||
|
||||
$rtn = [];
|
||||
$args = explode(';', $args);
|
||||
|
||||
foreach ($args as $arg) {
|
||||
$arg = explode(':', $arg);
|
||||
|
||||
if (count($arg) == 2) {
|
||||
|
||||
$key = trim($arg[0]);
|
||||
$val = trim($arg[1]);
|
||||
|
||||
|
@ -516,7 +524,6 @@ class Template extends View
|
|||
}
|
||||
|
||||
foreach ($args['variables'] as $variable) {
|
||||
|
||||
$variable = explode('=>', $variable);
|
||||
$variable = array_map('trim', $variable);
|
||||
|
||||
|
@ -533,7 +540,7 @@ class Template extends View
|
|||
|
||||
protected function callHelperFunction($args)
|
||||
{
|
||||
$helper = $args['helper'];
|
||||
$helper = $args['helper'];
|
||||
$function = $args['method'];
|
||||
|
||||
return $this->{$helper}()->{$function}();
|
||||
|
|
|
@ -308,11 +308,11 @@ class Builder implements LoggerAwareInterface
|
|||
/**
|
||||
* Find a binary required by a plugin.
|
||||
*
|
||||
* @param string $binary
|
||||
* @param bool $quiet Returns null instead of throwing an exception.
|
||||
* @param string $priorityPath
|
||||
* @param array|string $binary
|
||||
* @param bool $quiet Returns null instead of throwing an exception.
|
||||
* @param string $priorityPath
|
||||
*
|
||||
* @return null|string
|
||||
* @return string|false
|
||||
*
|
||||
* @throws \Exception when no binary has been found and $quiet is false.
|
||||
*/
|
||||
|
|
|
@ -13,7 +13,7 @@ use Symfony\Component\Console\Question\Question;
|
|||
|
||||
/**
|
||||
* Create admin command - creates an admin user
|
||||
*
|
||||
*
|
||||
* @author Wogan May (@woganmay)
|
||||
*/
|
||||
class CreateAdminCommand extends Command
|
||||
|
@ -38,9 +38,9 @@ class CreateAdminCommand extends Command
|
|||
$this
|
||||
->setName('php-censor:create-admin')
|
||||
|
||||
->addOption('admin-name', null, InputOption::VALUE_OPTIONAL, 'Admin name')
|
||||
->addOption('admin-name', null, InputOption::VALUE_OPTIONAL, 'Admin name')
|
||||
->addOption('admin-password', null, InputOption::VALUE_OPTIONAL, 'Admin password')
|
||||
->addOption('admin-email', null, InputOption::VALUE_OPTIONAL, 'Admin email')
|
||||
->addOption('admin-email', null, InputOption::VALUE_OPTIONAL, 'Admin email')
|
||||
|
||||
->setDescription('Create an admin user');
|
||||
}
|
||||
|
|
|
@ -47,12 +47,14 @@ class CreateBuildCommand extends Command
|
|||
{
|
||||
$this
|
||||
->setName('php-censor:create-build')
|
||||
->setDescription('Create a build for a project')
|
||||
|
||||
->addArgument('projectId', InputArgument::REQUIRED, 'A project ID')
|
||||
->addOption('commit', null, InputOption::VALUE_OPTIONAL, 'Commit ID to build')
|
||||
->addOption('branch', null, InputOption::VALUE_OPTIONAL, 'Branch to build')
|
||||
->addOption('email', null, InputOption::VALUE_OPTIONAL, 'Committer email')
|
||||
->addOption('message', null, InputOption::VALUE_OPTIONAL, 'Commit message');
|
||||
->addOption('message', null, InputOption::VALUE_OPTIONAL, 'Commit message')
|
||||
|
||||
->setDescription('Create a build for a project');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,19 +37,19 @@ class InstallCommand extends Command
|
|||
$this
|
||||
->setName('php-censor:install')
|
||||
|
||||
->addOption('url', null, InputOption::VALUE_OPTIONAL, 'PHP Censor installation URL')
|
||||
->addOption('db-type', null, InputOption::VALUE_OPTIONAL, 'Database type')
|
||||
->addOption('db-host', null, InputOption::VALUE_OPTIONAL, 'Database host')
|
||||
->addOption('db-port', null, InputOption::VALUE_OPTIONAL, 'Database port')
|
||||
->addOption('db-name', null, InputOption::VALUE_OPTIONAL, 'Database name')
|
||||
->addOption('db-user', null, InputOption::VALUE_OPTIONAL, 'Database user')
|
||||
->addOption('db-password', null, InputOption::VALUE_OPTIONAL, 'Database password')
|
||||
->addOption('admin-name', null, InputOption::VALUE_OPTIONAL, 'Admin name')
|
||||
->addOption('admin-password', null, InputOption::VALUE_OPTIONAL, 'Admin password')
|
||||
->addOption('admin-email', null, InputOption::VALUE_OPTIONAL, 'Admin email')
|
||||
->addOption('queue-use', null, InputOption::VALUE_OPTIONAL, 'Don\'t ask for queue details', true)
|
||||
->addOption('queue-host', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue server hostname')
|
||||
->addOption('queue-name', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue name')
|
||||
->addOption('url', null, InputOption::VALUE_OPTIONAL, 'PHP Censor installation URL')
|
||||
->addOption('db-type', null, InputOption::VALUE_OPTIONAL, 'Database type')
|
||||
->addOption('db-host', null, InputOption::VALUE_OPTIONAL, 'Database host')
|
||||
->addOption('db-port', null, InputOption::VALUE_OPTIONAL, 'Database port')
|
||||
->addOption('db-name', null, InputOption::VALUE_OPTIONAL, 'Database name')
|
||||
->addOption('db-user', null, InputOption::VALUE_OPTIONAL, 'Database user')
|
||||
->addOption('db-password', null, InputOption::VALUE_OPTIONAL, 'Database password')
|
||||
->addOption('admin-name', null, InputOption::VALUE_OPTIONAL, 'Admin name')
|
||||
->addOption('admin-password', null, InputOption::VALUE_OPTIONAL, 'Admin password')
|
||||
->addOption('admin-email', null, InputOption::VALUE_OPTIONAL, 'Admin email')
|
||||
->addOption('queue-use', null, InputOption::VALUE_OPTIONAL, 'Don\'t ask for queue details', true)
|
||||
->addOption('queue-host', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue server hostname')
|
||||
->addOption('queue-name', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue name')
|
||||
->addOption('config-from-file', null, InputOption::VALUE_OPTIONAL, 'Take config from file and ignore options', false)
|
||||
|
||||
->setDescription('Install PHP Censor');
|
||||
|
@ -467,7 +467,6 @@ class InstallCommand extends Command
|
|||
unset($pdo);
|
||||
|
||||
return true;
|
||||
|
||||
} catch (Exception $ex) {
|
||||
$output->writeln('<error>PHP Censor could not connect to database with the details provided. Please try again.</error>');
|
||||
$output->writeln('<error>' . $ex->getMessage() . '</error>');
|
||||
|
|
|
@ -18,7 +18,7 @@ use PHPCensor\Model\Build;
|
|||
|
||||
/**
|
||||
* Run console command - Runs any pending builds.
|
||||
*
|
||||
*
|
||||
* @author Dan Cryer <dan@block8.co.uk>
|
||||
*/
|
||||
class RunCommand extends Command
|
||||
|
@ -52,8 +52,10 @@ class RunCommand extends Command
|
|||
{
|
||||
$this
|
||||
->setName('php-censor:run-builds')
|
||||
->setDescription('Run all pending PHP Censor builds')
|
||||
->addOption('debug', null, null, 'Run PHP Censor in debug mode');
|
||||
|
||||
->addOption('debug', null, null, 'Run PHP Censor in debug mode')
|
||||
|
||||
->setDescription('Run all pending PHP Censor builds');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,7 +83,7 @@ class RunCommand extends Command
|
|||
|
||||
$this->logger->pushProcessor(new LoggedBuildContextTidier());
|
||||
$this->logger->addInfo('Finding builds to process');
|
||||
|
||||
|
||||
/** @var BuildStore $buildStore */
|
||||
$buildStore = Factory::getStore('Build');
|
||||
$result = $buildStore->getByStatus(Build::STATUS_PENDING, $this->maxBuilds);
|
||||
|
|
|
@ -55,8 +55,10 @@ class ScheduleBuildCommand extends Command
|
|||
{
|
||||
$this
|
||||
->setName('php-censor:schedule-build')
|
||||
->setDescription('Schedules a build for active projects which have not been ran by X days')
|
||||
->addArgument('days', InputArgument::REQUIRED, 'Since specified days');
|
||||
|
||||
->addArgument('days', InputArgument::REQUIRED, 'Since specified days')
|
||||
|
||||
->setDescription('Schedules a build for active projects which have not been ran by X days');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,8 +41,10 @@ class WorkerCommand extends Command
|
|||
{
|
||||
$this
|
||||
->setName('php-censor:worker')
|
||||
->setDescription('Runs the PHP Censor build worker.')
|
||||
->addOption('debug', null, null, 'Run PHP Censor in Debug Mode');
|
||||
|
||||
->addOption('debug', null, null, 'Run PHP Censor in Debug Mode')
|
||||
|
||||
->setDescription('Runs the PHP Censor build worker.');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
|
|
|
@ -11,7 +11,7 @@ use PHPCensor\Model\User;
|
|||
|
||||
/**
|
||||
* Project Controller - Allows users to create, edit and view projects.
|
||||
*
|
||||
*
|
||||
* @author Dan Cryer <dan@block8.co.uk>
|
||||
*/
|
||||
class GroupController extends Controller
|
||||
|
@ -46,7 +46,7 @@ class GroupController extends Controller
|
|||
];
|
||||
$projects_active = b8\Store\Factory::getStore('Project')->getByGroupId($group->getId(), false);
|
||||
$projects_archived = b8\Store\Factory::getStore('Project')->getByGroupId($group->getId(), true);
|
||||
|
||||
|
||||
$thisGroup['projects'] = array_merge($projects_active['items'], $projects_archived['items']);
|
||||
$groups[] = $thisGroup;
|
||||
}
|
||||
|
|
|
@ -647,30 +647,30 @@ class WebhookController extends Controller
|
|||
*/
|
||||
protected function gogsPullRequest(Project $project, array $payload)
|
||||
{
|
||||
$pull_request = $payload['pull_request'];
|
||||
$head_branch = $pull_request['head_branch'];
|
||||
$pullRequest = $payload['pull_request'];
|
||||
$headBranch = $pullRequest['head_branch'];
|
||||
|
||||
$action = $payload['action'];
|
||||
$active_actions = ['opened', 'reopened', 'label_updated', 'label_cleared'];
|
||||
$inactive_actions = ['closed'];
|
||||
$action = $payload['action'];
|
||||
$activeActions = ['opened', 'reopened', 'label_updated', 'label_cleared'];
|
||||
$inactiveActions = ['closed'];
|
||||
|
||||
$state = $pull_request['state'];
|
||||
$active_states = ['open'];
|
||||
$inactive_states = ['closed'];
|
||||
$state = $pullRequest['state'];
|
||||
$activeStates = ['open'];
|
||||
$inactiveStates = ['closed'];
|
||||
|
||||
if (!in_array($action, $active_actions) and !in_array($action, $inactive_actions)) {
|
||||
if (!in_array($action, $activeActions) and !in_array($action, $inactiveActions)) {
|
||||
return ['status' => 'ignored', 'message' => 'Action ' . $action . ' ignored'];
|
||||
}
|
||||
if (!in_array($state, $active_states) and !in_array($state, $inactive_states)) {
|
||||
if (!in_array($state, $activeStates) and !in_array($state, $inactiveStates)) {
|
||||
return ['status' => 'ignored', 'message' => 'State ' . $state . ' ignored'];
|
||||
}
|
||||
|
||||
$envs = [];
|
||||
|
||||
// Get environment form labels
|
||||
if (in_array($action, $active_actions) and in_array($state, $active_states)) {
|
||||
if (isset($pull_request['labels']) && is_array($pull_request['labels'])) {
|
||||
foreach ($pull_request['labels'] as $label) {
|
||||
if (in_array($action, $activeActions) and in_array($state, $activeStates)) {
|
||||
if (isset($pullRequest['labels']) && is_array($pullRequest['labels'])) {
|
||||
foreach ($pullRequest['labels'] as $label) {
|
||||
if (strpos($label['name'], 'env:') === 0) {
|
||||
$envs[] = substr($label['name'], 4);
|
||||
}
|
||||
|
@ -678,42 +678,42 @@ class WebhookController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
$envs_updated = [];
|
||||
$env_objs = $project->getEnvironmentsObjects();
|
||||
$store = Factory::getStore('Environment', 'PHPCensor');;
|
||||
foreach ($env_objs['items'] as $environment) {
|
||||
$envsUpdated = [];
|
||||
$envObjects = $project->getEnvironmentsObjects();
|
||||
$store = Factory::getStore('Environment', 'PHPCensor');
|
||||
foreach ($envObjects['items'] as $environment) {
|
||||
$branches = $environment->getBranches();
|
||||
if (in_array($environment->getName(), $envs)) {
|
||||
if (!in_array($head_branch, $branches)) {
|
||||
if (!in_array($headBranch, $branches)) {
|
||||
// Add branch to environment
|
||||
$branches[] = $head_branch;
|
||||
$branches[] = $headBranch;
|
||||
$environment->setBranches($branches);
|
||||
$store->save($environment);
|
||||
$envs_updated[] = $environment->getName();
|
||||
$envsUpdated[] = $environment->getName();
|
||||
}
|
||||
} else {
|
||||
if (in_array($head_branch, $branches)) {
|
||||
if (in_array($headBranch, $branches)) {
|
||||
// Remove branch from environment
|
||||
$branches = array_diff($branches, [$head_branch]);
|
||||
$branches = array_diff($branches, [$headBranch]);
|
||||
$environment->setBranches($branches);
|
||||
$store->save($environment);
|
||||
$envs_updated[] = $environment->getName();
|
||||
$envsUpdated[] = $environment->getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (($state == 'closed') and $pull_request['merged']) {
|
||||
// update base branch enviroments
|
||||
$environment_names = $project->getEnvironmentsNamesByBranch($pull_request['base_branch']);
|
||||
$envs_updated = array_merge($envs_updated, $environment_names);
|
||||
if (($state == 'closed') and $pullRequest['merged']) {
|
||||
// update base branch environments
|
||||
$environmentNames = $project->getEnvironmentsNamesByBranch($pullRequest['base_branch']);
|
||||
$envsUpdated = array_merge($envsUpdated, $environmentNames);
|
||||
}
|
||||
|
||||
$envs_updated = array_unique($envs_updated);
|
||||
if (!empty($envs_updated)) {
|
||||
foreach ($envs_updated as $environment_name) {
|
||||
$envsUpdated = array_unique($envsUpdated);
|
||||
if (!empty($envsUpdated)) {
|
||||
foreach ($envsUpdated as $environmentName) {
|
||||
$this->buildService->createBuild(
|
||||
$project,
|
||||
$environment_name,
|
||||
$environmentName,
|
||||
'',
|
||||
$project->getBranch(),
|
||||
null,
|
||||
|
@ -725,7 +725,7 @@ class WebhookController extends Controller
|
|||
);
|
||||
}
|
||||
|
||||
return ['status' => 'ok', 'message' => 'Branch environments updated ' . join(', ', $envs_updated)];
|
||||
return ['status' => 'ok', 'message' => 'Branch environments updated ' . join(', ', $envsUpdated)];
|
||||
}
|
||||
|
||||
return ['status' => 'ignored', 'message' => 'Branch environments not changed'];
|
||||
|
|
|
@ -36,6 +36,9 @@ class CommandExecutor implements CommandExecutorInterface
|
|||
*/
|
||||
protected $lastError;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
public $logExecOutput = true;
|
||||
|
||||
/**
|
||||
|
@ -100,7 +103,6 @@ class CommandExecutor implements CommandExecutorInterface
|
|||
|
||||
$lastOutput = '';
|
||||
$lastError = '';
|
||||
|
||||
if (is_resource($process)) {
|
||||
fclose($pipes[0]);
|
||||
|
||||
|
@ -109,7 +111,7 @@ class CommandExecutor implements CommandExecutorInterface
|
|||
$status = proc_close($process);
|
||||
|
||||
$lastOutput = $this->replaceIllegalCharacters($lastOutput);
|
||||
$lastError = $this->replaceIllegalCharacters($lastError);
|
||||
$lastError = $this->replaceIllegalCharacters($lastError);
|
||||
}
|
||||
|
||||
$this->lastOutput = array_filter(explode(PHP_EOL, $lastOutput));
|
||||
|
@ -138,7 +140,7 @@ class CommandExecutor implements CommandExecutorInterface
|
|||
/**
|
||||
* Reads from array of streams as data becomes available.
|
||||
*
|
||||
* @param array $descriptors
|
||||
* @param array $descriptors
|
||||
*
|
||||
* @return string[] data read from each descriptor
|
||||
*/
|
||||
|
@ -167,20 +169,20 @@ class CommandExecutor implements CommandExecutorInterface
|
|||
return $outputs;
|
||||
}
|
||||
|
||||
private static function replaceIllegalCharacters($utf8String)
|
||||
/**
|
||||
* @param string $utf8String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function replaceIllegalCharacters($utf8String)
|
||||
{
|
||||
$substCharCode = 65533;
|
||||
mb_substitute_character($substCharCode);
|
||||
$legalUtf8String = mb_convert_encoding($utf8String, 'utf8', 'utf8');
|
||||
|
||||
$regexp = '/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]' .
|
||||
'|[\x00-\x7F][\x80-\xBF]+' .
|
||||
'|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*' .
|
||||
'|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})' .
|
||||
'|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S';
|
||||
$cleanUtf8String = preg_replace($regexp, chr($substCharCode), $legalUtf8String);
|
||||
|
||||
return $cleanUtf8String;
|
||||
return preg_replace($regexp, '<27>', $utf8String);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -207,7 +209,7 @@ class CommandExecutor implements CommandExecutorInterface
|
|||
* @param string $composerBin
|
||||
* @param string $binary
|
||||
*
|
||||
* @return false|string
|
||||
* @return string|false
|
||||
*/
|
||||
protected function findBinaryLocal($composerBin, $binary)
|
||||
{
|
||||
|
@ -223,7 +225,7 @@ class CommandExecutor implements CommandExecutorInterface
|
|||
/**
|
||||
* @param string $binary
|
||||
*
|
||||
* @return false|string
|
||||
* @return string|false
|
||||
*/
|
||||
protected function findBinaryGlobal($binary)
|
||||
{
|
||||
|
@ -241,7 +243,7 @@ class CommandExecutor implements CommandExecutorInterface
|
|||
*
|
||||
* @param string $binary
|
||||
*
|
||||
* @return false|string
|
||||
* @return string|false
|
||||
*/
|
||||
protected function findBinarySystem($binary)
|
||||
{
|
||||
|
@ -258,11 +260,11 @@ class CommandExecutor implements CommandExecutorInterface
|
|||
/**
|
||||
* Find a binary required by a plugin.
|
||||
*
|
||||
* @param string $binary
|
||||
* @param bool $quiet Returns null instead of throwing an exception.
|
||||
* @param string $priorityPath
|
||||
* @param array|string $binary
|
||||
* @param bool $quiet Returns null instead of throwing an exception.
|
||||
* @param string $priorityPath
|
||||
*
|
||||
* @return null|string
|
||||
* @return string|false
|
||||
*
|
||||
* @throws \Exception when no binary has been found and $quiet is false.
|
||||
*/
|
||||
|
@ -317,7 +319,7 @@ class CommandExecutor implements CommandExecutorInterface
|
|||
}
|
||||
|
||||
if ($quiet) {
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
throw new Exception(sprintf('Could not find %s', implode('/', $binary)));
|
||||
|
|
|
@ -24,11 +24,11 @@ interface CommandExecutorInterface
|
|||
/**
|
||||
* Find a binary required by a plugin.
|
||||
*
|
||||
* @param string $binary
|
||||
* @param bool $quiet Returns null instead of throwing an exception.
|
||||
* @param string $priorityPath
|
||||
* @param array|string $binary
|
||||
* @param bool $quiet Returns null instead of throwing an exception.
|
||||
* @param string $priorityPath
|
||||
*
|
||||
* @return null|string
|
||||
* @return string|false
|
||||
*
|
||||
* @throws \Exception when no binary has been found and $quiet is false.
|
||||
*/
|
||||
|
|
|
@ -55,10 +55,10 @@ abstract class Plugin
|
|||
/**
|
||||
* Find a binary required by a plugin.
|
||||
*
|
||||
* @param string $binary
|
||||
* @param boolean $quiet Returns null instead of throwing an exception.
|
||||
* @param array|string $binary
|
||||
* @param boolean $quiet Returns null instead of throwing an exception.
|
||||
*
|
||||
* @return null|string
|
||||
* @return string|false
|
||||
*
|
||||
* @throws \Exception when no binary has been found and $quiet is false.
|
||||
*/
|
||||
|
|
|
@ -10,7 +10,7 @@ use PHPCensor\ZeroConfigPluginInterface;
|
|||
|
||||
/**
|
||||
* Composer Plugin - Provides access to Composer functionality.
|
||||
*
|
||||
*
|
||||
* @author Dan Cryer <dan@block8.co.uk>
|
||||
*/
|
||||
class Composer extends Plugin implements ZeroConfigPluginInterface
|
||||
|
@ -18,7 +18,7 @@ class Composer extends Plugin implements ZeroConfigPluginInterface
|
|||
protected $directory;
|
||||
protected $action;
|
||||
protected $preferDist;
|
||||
protected $nodev;
|
||||
protected $noDev;
|
||||
protected $ignorePlatformReqs;
|
||||
protected $preferSource;
|
||||
|
||||
|
@ -42,7 +42,7 @@ class Composer extends Plugin implements ZeroConfigPluginInterface
|
|||
$this->action = 'install';
|
||||
$this->preferDist = false;
|
||||
$this->preferSource = false;
|
||||
$this->nodev = false;
|
||||
$this->noDev = false;
|
||||
$this->ignorePlatformReqs = false;
|
||||
|
||||
if (array_key_exists('directory', $options)) {
|
||||
|
@ -63,7 +63,7 @@ class Composer extends Plugin implements ZeroConfigPluginInterface
|
|||
}
|
||||
|
||||
if (array_key_exists('no_dev', $options)) {
|
||||
$this->nodev = (bool)$options['no_dev'];
|
||||
$this->noDev = (bool)$options['no_dev'];
|
||||
}
|
||||
|
||||
if (array_key_exists('ignore_platform_reqs', $options)) {
|
||||
|
@ -107,7 +107,7 @@ class Composer extends Plugin implements ZeroConfigPluginInterface
|
|||
$cmd .= ' --prefer-source';
|
||||
}
|
||||
|
||||
if ($this->nodev) {
|
||||
if ($this->noDev) {
|
||||
$this->builder->log('Using --no-dev flag');
|
||||
$cmd .= ' --no-dev';
|
||||
}
|
||||
|
|
|
@ -6,13 +6,11 @@ use PHPCensor\Plugin;
|
|||
|
||||
/**
|
||||
* Environment variable plugin
|
||||
*
|
||||
*
|
||||
* @author Steve Kamerman <stevekamerman@gmail.com>
|
||||
*/
|
||||
class Env extends Plugin
|
||||
{
|
||||
protected $env_vars;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
@ -20,7 +18,7 @@ class Env extends Plugin
|
|||
{
|
||||
return 'env';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds the specified environment variables to the builder environment
|
||||
*/
|
||||
|
@ -30,13 +28,13 @@ class Env extends Plugin
|
|||
foreach ($this->options as $key => $value) {
|
||||
if (is_numeric($key)) {
|
||||
// This allows the developer to specify env vars like " - FOO=bar" or " - FOO: bar"
|
||||
$env_var = is_array($value)? key($value).'='.current($value): $value;
|
||||
$envVar = is_array($value)? key($value).'='.current($value): $value;
|
||||
} else {
|
||||
// This allows the standard syntax: "FOO: bar"
|
||||
$env_var = "$key=$value";
|
||||
$envVar = "$key=$value";
|
||||
}
|
||||
|
||||
if (!putenv($this->builder->interpolate($env_var))) {
|
||||
if (!putenv($this->builder->interpolate($envVar))) {
|
||||
$success = false;
|
||||
$this->builder->logFailure('Unable to set environment variable');
|
||||
}
|
||||
|
|
|
@ -10,12 +10,12 @@ use PHPCensor\Plugin;
|
|||
|
||||
/**
|
||||
* Flowdock Plugin
|
||||
*
|
||||
*
|
||||
* @author Petr Cervenka <petr@nanosolutions.io>
|
||||
*/
|
||||
class FlowdockNotify extends Plugin
|
||||
{
|
||||
protected $api_key;
|
||||
protected $apiKey;
|
||||
protected $email;
|
||||
protected $message;
|
||||
|
||||
|
@ -29,7 +29,7 @@ class FlowdockNotify extends Plugin
|
|||
{
|
||||
return 'flowdock_notify';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -40,7 +40,7 @@ class FlowdockNotify extends Plugin
|
|||
if (!is_array($options) || !isset($options['api_key'])) {
|
||||
throw new \Exception('Please define the api_key for Flowdock Notify plugin!');
|
||||
}
|
||||
$this->api_key = trim($options['api_key']);
|
||||
$this->apiKey = trim($options['api_key']);
|
||||
$this->message = isset($options['message']) ? $options['message'] : self::MESSAGE_DEFAULT;
|
||||
$this->email = isset($options['email']) ? $options['email'] : 'PHP Censor';
|
||||
}
|
||||
|
@ -53,9 +53,9 @@ class FlowdockNotify extends Plugin
|
|||
public function execute()
|
||||
{
|
||||
|
||||
$message = $this->builder->interpolate($this->message);
|
||||
$message = $this->builder->interpolate($this->message);
|
||||
$successfulBuild = $this->build->isSuccessful() ? 'Success' : 'Failed';
|
||||
$push = new Push($this->api_key);
|
||||
$push = new Push($this->apiKey);
|
||||
$flowMessage = TeamInboxMessage::create()
|
||||
->setSource("PHPCensor")
|
||||
->setFromAddress($this->email)
|
||||
|
|
|
@ -12,13 +12,14 @@ use \PHPCensor\Plugin;
|
|||
|
||||
/**
|
||||
* Integrates PHPCensor with Mage: https://github.com/andres-montanez/Magallanes
|
||||
*
|
||||
* @package PHPCensor
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Mage extends Plugin
|
||||
{
|
||||
protected $mage_bin = 'mage';
|
||||
protected $mage_env;
|
||||
protected $mageBin = 'mage';
|
||||
protected $mageEnv;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -37,11 +38,11 @@ class Mage extends Plugin
|
|||
|
||||
$config = $builder->getSystemConfig('mage');
|
||||
if (!empty($config['bin'])) {
|
||||
$this->mage_bin = $config['bin'];
|
||||
$this->mageBin = $config['bin'];
|
||||
}
|
||||
|
||||
if (isset($options['env'])) {
|
||||
$this->mage_env = $builder->interpolate($options['env']);
|
||||
$this->mageEnv = $builder->interpolate($options['env']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,12 +51,12 @@ class Mage extends Plugin
|
|||
*/
|
||||
public function execute()
|
||||
{
|
||||
if (empty($this->mage_env)) {
|
||||
if (empty($this->mageEnv)) {
|
||||
$this->builder->logFailure('You must specify environment.');
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = $this->builder->executeCommand($this->mage_bin . ' deploy to:' . $this->mage_env);
|
||||
$result = $this->builder->executeCommand($this->mageBin . ' deploy to:' . $this->mageEnv);
|
||||
|
||||
try {
|
||||
$this->builder->log('########## MAGE LOG BEGIN ##########');
|
||||
|
@ -75,12 +76,12 @@ class Mage extends Plugin
|
|||
*/
|
||||
protected function getMageLog()
|
||||
{
|
||||
$logs_dir = $this->build->getBuildPath() . '/.mage/logs';
|
||||
if (!is_dir($logs_dir)) {
|
||||
$logsDir = $this->build->getBuildPath() . '/.mage/logs';
|
||||
if (!is_dir($logsDir)) {
|
||||
throw new \Exception('Log directory not found');
|
||||
}
|
||||
|
||||
$list = scandir($logs_dir);
|
||||
$list = scandir($logsDir);
|
||||
if ($list === false) {
|
||||
throw new \Exception('Log dir read fail');
|
||||
}
|
||||
|
@ -97,17 +98,17 @@ class Mage extends Plugin
|
|||
throw new \Exception('Logs sort fail');
|
||||
}
|
||||
|
||||
$last_log_file = end($list);
|
||||
if ($last_log_file === false) {
|
||||
$lastLogFile = end($list);
|
||||
if ($lastLogFile === false) {
|
||||
throw new \Exception('Get last Log name fail');
|
||||
}
|
||||
|
||||
$log_content = file_get_contents($logs_dir . '/' . $last_log_file);
|
||||
if ($log_content === false) {
|
||||
$logContent = file_get_contents($logsDir . '/' . $lastLogFile);
|
||||
if ($logContent === false) {
|
||||
throw new \Exception('Get last Log content fail');
|
||||
}
|
||||
|
||||
$lines = explode("\n", $log_content);
|
||||
$lines = explode("\n", $logContent);
|
||||
$lines = array_map('trim', $lines);
|
||||
$lines = array_filter($lines);
|
||||
|
||||
|
|
|
@ -12,14 +12,15 @@ use \PHPCensor\Plugin;
|
|||
|
||||
/**
|
||||
* Integrates PHPCensor with Mage v3: https://github.com/andres-montanez/Magallanes
|
||||
*
|
||||
* @package PHPCensor
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Mage3 extends Plugin
|
||||
{
|
||||
protected $mage_bin = 'mage';
|
||||
protected $mage_env;
|
||||
protected $mage_log_dir;
|
||||
protected $mageBin = 'mage';
|
||||
protected $mageEnv;
|
||||
protected $mageLogDir;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -38,15 +39,15 @@ class Mage3 extends Plugin
|
|||
|
||||
$config = $builder->getSystemConfig('mage3');
|
||||
if (!empty($config['bin'])) {
|
||||
$this->mage_bin = $config['bin'];
|
||||
$this->mageBin = $config['bin'];
|
||||
}
|
||||
|
||||
if (isset($options['env'])) {
|
||||
$this->mage_env = $builder->interpolate($options['env']);
|
||||
$this->mageEnv = $builder->interpolate($options['env']);
|
||||
}
|
||||
|
||||
if (isset($options['log_dir'])) {
|
||||
$this->mage_log_dir = $builder->interpolate($options['log_dir']);
|
||||
$this->mageLogDir = $builder->interpolate($options['log_dir']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,12 +56,12 @@ class Mage3 extends Plugin
|
|||
*/
|
||||
public function execute()
|
||||
{
|
||||
if (empty($this->mage_env)) {
|
||||
if (empty($this->mageEnv)) {
|
||||
$this->builder->logFailure('You must specify environment.');
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = $this->builder->executeCommand($this->mage_bin . ' -n deploy ' . $this->mage_env);
|
||||
$result = $this->builder->executeCommand($this->mageBin . ' -n deploy ' . $this->mageEnv);
|
||||
|
||||
try {
|
||||
$this->builder->log('########## MAGE LOG BEGIN ##########');
|
||||
|
@ -80,12 +81,12 @@ class Mage3 extends Plugin
|
|||
*/
|
||||
protected function getMageLog()
|
||||
{
|
||||
$logs_dir = $this->build->getBuildPath() . (!empty($this->mage_log_dir) ? '/' . $this->mage_log_dir : '');
|
||||
if (!is_dir($logs_dir)) {
|
||||
$logsDir = $this->build->getBuildPath() . (!empty($this->mageLogDir) ? '/' . $this->mageLogDir : '');
|
||||
if (!is_dir($logsDir)) {
|
||||
throw new \Exception('Log directory not found');
|
||||
}
|
||||
|
||||
$list = scandir($logs_dir);
|
||||
$list = scandir($logsDir);
|
||||
if ($list === false) {
|
||||
throw new \Exception('Log dir read fail');
|
||||
}
|
||||
|
@ -102,17 +103,17 @@ class Mage3 extends Plugin
|
|||
throw new \Exception('Logs sort fail');
|
||||
}
|
||||
|
||||
$last_log_file = end($list);
|
||||
if ($last_log_file === false) {
|
||||
$lastLogFile = end($list);
|
||||
if ($lastLogFile === false) {
|
||||
throw new \Exception('Get last Log name fail');
|
||||
}
|
||||
|
||||
$log_content = file_get_contents($logs_dir . '/' . $last_log_file);
|
||||
if ($log_content === false) {
|
||||
$logContent = file_get_contents($logsDir . '/' . $lastLogFile);
|
||||
if ($logContent === false) {
|
||||
throw new \Exception('Get last Log content fail');
|
||||
}
|
||||
|
||||
$lines = explode("\n", $log_content);
|
||||
$lines = explode("\n", $logContent);
|
||||
$lines = array_map('trim', $lines);
|
||||
$lines = array_filter($lines);
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use b8\Database;
|
|||
|
||||
/**
|
||||
* MySQL Plugin - Provides access to a MySQL database.
|
||||
*
|
||||
*
|
||||
* @author Dan Cryer <dan@block8.co.uk>
|
||||
* @author Steve Kamerman <stevekamerman@gmail.com>
|
||||
*/
|
||||
|
@ -110,15 +110,15 @@ class Mysql extends Plugin
|
|||
throw new \Exception('Import statement must contain a \'file\' key');
|
||||
}
|
||||
|
||||
$import_file = $this->builder->buildPath . $this->builder->interpolate($query['file']);
|
||||
if (!is_readable($import_file)) {
|
||||
throw new \Exception(sprintf('Cannot open SQL import file: %s', $import_file));
|
||||
$importFile = $this->builder->buildPath . $this->builder->interpolate($query['file']);
|
||||
if (!is_readable($importFile)) {
|
||||
throw new \Exception(sprintf('Cannot open SQL import file: %s', $importFile));
|
||||
}
|
||||
|
||||
$database = isset($query['database']) ? $this->builder->interpolate($query['database']) : null;
|
||||
|
||||
$import_command = $this->getImportCommand($import_file, $database);
|
||||
if (!$this->builder->executeCommand($import_command)) {
|
||||
$importCommand = $this->getImportCommand($importFile, $database);
|
||||
if (!$this->builder->executeCommand($importCommand)) {
|
||||
throw new \Exception('Unable to execute SQL file');
|
||||
}
|
||||
|
||||
|
@ -140,15 +140,15 @@ class Mysql extends Plugin
|
|||
'gz' => '| gzip --decompress',
|
||||
];
|
||||
|
||||
$extension = strtolower(pathinfo($import_file, PATHINFO_EXTENSION));
|
||||
$decomp_cmd = '';
|
||||
$extension = strtolower(pathinfo($import_file, PATHINFO_EXTENSION));
|
||||
$decompressionCmd = '';
|
||||
if (array_key_exists($extension, $decompression)) {
|
||||
$decomp_cmd = $decompression[$extension];
|
||||
$decompressionCmd = $decompression[$extension];
|
||||
}
|
||||
|
||||
$args = [
|
||||
':import_file' => escapeshellarg($import_file),
|
||||
':decomp_cmd' => $decomp_cmd,
|
||||
':decomp_cmd' => $decompressionCmd,
|
||||
':host' => escapeshellarg($this->host),
|
||||
':user' => escapeshellarg($this->user),
|
||||
':pass' => (!$this->pass) ? '' : '-p' . escapeshellarg($this->pass),
|
||||
|
|
|
@ -8,7 +8,7 @@ use PHPCensor\Plugin;
|
|||
|
||||
/**
|
||||
* Create a ZIP or TAR.GZ archive of the entire build.
|
||||
*
|
||||
*
|
||||
* @author Dan Cryer <dan@block8.co.uk>
|
||||
*/
|
||||
class PackageBuild extends Plugin
|
||||
|
@ -24,7 +24,7 @@ class PackageBuild extends Plugin
|
|||
{
|
||||
return 'package_build';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -58,7 +58,7 @@ class PackageBuild extends Plugin
|
|||
$filename = str_replace('%time%', date('Hi'), $filename);
|
||||
$filename = preg_replace('/([^a-zA-Z0-9_-]+)/', '', $filename);
|
||||
|
||||
$curdir = getcwd();
|
||||
$currentDir = getcwd();
|
||||
chdir($this->builder->buildPath);
|
||||
|
||||
if (!is_array($this->format)) {
|
||||
|
@ -79,7 +79,7 @@ class PackageBuild extends Plugin
|
|||
$success = $this->builder->executeCommand($cmd, $this->directory, $filename);
|
||||
}
|
||||
|
||||
chdir($curdir);
|
||||
chdir($currentDir);
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class Phing extends Plugin
|
|||
{
|
||||
return 'phing';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -106,7 +106,7 @@ class Phing extends Plugin
|
|||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
public function getTargets()
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ use PHPCensor\ZeroConfigPluginInterface;
|
|||
|
||||
/**
|
||||
* PHP Code Sniffer Plugin - Allows PHP Code Sniffer testing.
|
||||
*
|
||||
*
|
||||
* @author Dan Cryer <dan@block8.co.uk>
|
||||
*/
|
||||
class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
||||
|
@ -34,7 +34,7 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $tab_width;
|
||||
protected $tabWidth;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
@ -44,12 +44,12 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
|||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $allowed_errors;
|
||||
protected $allowedErrors;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $allowed_warnings;
|
||||
protected $allowedWarnings;
|
||||
|
||||
/**
|
||||
* @var string, based on the assumption the root may not hold the code to be tested, extends the base path
|
||||
|
@ -68,12 +68,12 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
|||
/**
|
||||
* @var null|int
|
||||
*/
|
||||
protected $error_severity = null;
|
||||
protected $errorSeverity = null;
|
||||
|
||||
/**
|
||||
* @var null|int
|
||||
*/
|
||||
protected $warning_severity = null;
|
||||
protected $warningSeverity = null;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
|
@ -93,24 +93,24 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
|||
$this->suffixes = ['php'];
|
||||
$this->directory = $this->builder->buildPath;
|
||||
$this->standard = 'PSR2';
|
||||
$this->tab_width = '';
|
||||
$this->tabWidth = '';
|
||||
$this->encoding = '';
|
||||
$this->path = '';
|
||||
$this->ignore = $this->builder->ignore;
|
||||
$this->allowed_warnings = 0;
|
||||
$this->allowed_errors = 0;
|
||||
$this->allowedWarnings = 0;
|
||||
$this->allowedErrors = 0;
|
||||
|
||||
if (isset($options['zero_config']) && $options['zero_config']) {
|
||||
$this->allowed_warnings = -1;
|
||||
$this->allowed_errors = -1;
|
||||
$this->allowedWarnings = -1;
|
||||
$this->allowedErrors = -1;
|
||||
}
|
||||
|
||||
if (!empty($options['allowed_errors']) && is_int($options['allowed_errors'])) {
|
||||
$this->allowed_errors = $options['allowed_errors'];
|
||||
$this->allowedErrors = $options['allowed_errors'];
|
||||
}
|
||||
|
||||
if (!empty($options['allowed_warnings']) && is_int($options['allowed_warnings'])) {
|
||||
$this->allowed_warnings = $options['allowed_warnings'];
|
||||
$this->allowedWarnings = $options['allowed_warnings'];
|
||||
}
|
||||
|
||||
if (isset($options['suffixes'])) {
|
||||
|
@ -118,7 +118,7 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
|||
}
|
||||
|
||||
if (!empty($options['tab_width'])) {
|
||||
$this->tab_width = ' --tab-width='.$options['tab_width'];
|
||||
$this->tabWidth = ' --tab-width='.$options['tab_width'];
|
||||
}
|
||||
|
||||
if (!empty($options['encoding'])) {
|
||||
|
@ -138,11 +138,11 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
|||
}
|
||||
|
||||
if (isset($options['error_severity']) && is_int($options['error_severity'])) {
|
||||
$this->error_severity = $options['error_severity'];
|
||||
$this->errorSeverity = $options['error_severity'];
|
||||
}
|
||||
|
||||
if (isset($options['warning_severity']) && is_int($options['warning_severity'])) {
|
||||
$this->warning_severity = $options['warning_severity'];
|
||||
$this->warningSeverity = $options['warning_severity'];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
|||
$standard,
|
||||
$suffixes,
|
||||
$ignore,
|
||||
$this->tab_width,
|
||||
$this->tabWidth,
|
||||
$this->encoding,
|
||||
$this->builder->buildPath . $this->path,
|
||||
$severity,
|
||||
|
@ -198,11 +198,11 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
|||
$this->build->storeMeta('phpcs-warnings', $warnings);
|
||||
$this->build->storeMeta('phpcs-errors', $errors);
|
||||
|
||||
if ($this->allowed_warnings != -1 && $warnings > $this->allowed_warnings) {
|
||||
if ($this->allowedWarnings != -1 && $warnings > $this->allowedWarnings) {
|
||||
$success = false;
|
||||
}
|
||||
|
||||
if ($this->allowed_errors != -1 && $errors > $this->allowed_errors) {
|
||||
if ($this->allowedErrors != -1 && $errors > $this->allowedErrors) {
|
||||
$success = false;
|
||||
}
|
||||
|
||||
|
@ -237,13 +237,13 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPluginInterface
|
|||
}
|
||||
|
||||
$errorSeverity = '';
|
||||
if ($this->error_severity !== null) {
|
||||
$errorSeverity = ' --error-severity=' . $this->error_severity;
|
||||
if ($this->errorSeverity !== null) {
|
||||
$errorSeverity = ' --error-severity=' . $this->errorSeverity;
|
||||
}
|
||||
|
||||
$warningSeverity = '';
|
||||
if ($this->warning_severity !== null) {
|
||||
$warningSeverity = ' --warning-severity=' . $this->warning_severity;
|
||||
if ($this->warningSeverity !== null) {
|
||||
$warningSeverity = ' --warning-severity=' . $this->warningSeverity;
|
||||
}
|
||||
|
||||
return [$ignore, $standard, $suffixes, $severity, $errorSeverity, $warningSeverity];
|
||||
|
|
|
@ -11,7 +11,7 @@ use PHPCensor\ZeroConfigPluginInterface;
|
|||
|
||||
/**
|
||||
* PHP Docblock Checker Plugin - Checks your PHP files for appropriate uses of Docblocks
|
||||
*
|
||||
*
|
||||
* @author Dan Cryer <dan@block8.co.uk>
|
||||
*/
|
||||
class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface
|
||||
|
@ -33,7 +33,7 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface
|
|||
/**
|
||||
* @var integer
|
||||
*/
|
||||
protected $allowed_warnings;
|
||||
protected $allowedWarnings;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
|
@ -42,7 +42,7 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface
|
|||
{
|
||||
return 'php_docblock_checker';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -52,10 +52,10 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface
|
|||
|
||||
$this->ignore = $this->builder->ignore;
|
||||
$this->path = '';
|
||||
$this->allowed_warnings = 0;
|
||||
$this->allowedWarnings = 0;
|
||||
|
||||
if (isset($options['zero_config']) && $options['zero_config']) {
|
||||
$this->allowed_warnings = -1;
|
||||
$this->allowedWarnings = -1;
|
||||
}
|
||||
|
||||
if (array_key_exists('skip_classes', $options)) {
|
||||
|
@ -71,7 +71,7 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface
|
|||
}
|
||||
|
||||
if (array_key_exists('allowed_warnings', $options)) {
|
||||
$this->allowed_warnings = (int)$options['allowed_warnings'];
|
||||
$this->allowedWarnings = (int)$options['allowed_warnings'];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface
|
|||
$this->build->storeMeta('phpdoccheck-warnings', $errors);
|
||||
$this->reportErrors($output);
|
||||
|
||||
if ($this->allowed_warnings != -1 && $errors > $this->allowed_warnings) {
|
||||
if ($this->allowedWarnings != -1 && $errors > $this->allowedWarnings) {
|
||||
$success = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use PHPCensor\ZeroConfigPluginInterface;
|
|||
|
||||
/**
|
||||
* PHP Mess Detector Plugin - Allows PHP Mess Detector testing.
|
||||
*
|
||||
*
|
||||
* @author Dan Cryer <dan@block8.co.uk>
|
||||
*/
|
||||
class PhpMessDetector extends Plugin implements ZeroConfigPluginInterface
|
||||
|
@ -38,7 +38,7 @@ class PhpMessDetector extends Plugin implements ZeroConfigPluginInterface
|
|||
* @var array
|
||||
*/
|
||||
protected $rules;
|
||||
protected $allowed_warnings;
|
||||
protected $allowedWarnings;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
|
@ -59,10 +59,10 @@ class PhpMessDetector extends Plugin implements ZeroConfigPluginInterface
|
|||
$this->ignore = $this->builder->ignore;
|
||||
$this->path = '';
|
||||
$this->rules = ['codesize', 'unusedcode', 'naming'];
|
||||
$this->allowed_warnings = 0;
|
||||
$this->allowedWarnings = 0;
|
||||
|
||||
if (isset($options['zero_config']) && $options['zero_config']) {
|
||||
$this->allowed_warnings = -1;
|
||||
$this->allowedWarnings = -1;
|
||||
}
|
||||
|
||||
if (!empty($options['path'])) {
|
||||
|
@ -70,7 +70,7 @@ class PhpMessDetector extends Plugin implements ZeroConfigPluginInterface
|
|||
}
|
||||
|
||||
if (array_key_exists('allowed_warnings', $options)) {
|
||||
$this->allowed_warnings = (int)$options['allowed_warnings'];
|
||||
$this->allowedWarnings = (int)$options['allowed_warnings'];
|
||||
}
|
||||
|
||||
foreach (['rules', 'ignore', 'suffixes'] as $key) {
|
||||
|
@ -247,7 +247,7 @@ class PhpMessDetector extends Plugin implements ZeroConfigPluginInterface
|
|||
{
|
||||
$success = true;
|
||||
|
||||
if ($this->allowed_warnings != -1 && $errorCount > $this->allowed_warnings) {
|
||||
if ($this->allowedWarnings != -1 && $errorCount > $this->allowedWarnings) {
|
||||
$success = false;
|
||||
return $success;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use PHPCensor\Plugin;
|
|||
|
||||
/**
|
||||
* PHP Spec Plugin - Allows PHP Spec testing.
|
||||
*
|
||||
*
|
||||
* @author Dan Cryer <dan@block8.co.uk>
|
||||
*/
|
||||
class PhpSpec extends Plugin
|
||||
|
@ -25,7 +25,7 @@ class PhpSpec extends Plugin
|
|||
*/
|
||||
public function execute()
|
||||
{
|
||||
$curdir = getcwd();
|
||||
$currentDir = getcwd();
|
||||
chdir($this->builder->buildPath);
|
||||
|
||||
$phpspec = $this->findBinary(['phpspec', 'phpspec.php']);
|
||||
|
@ -33,7 +33,7 @@ class PhpSpec extends Plugin
|
|||
$success = $this->builder->executeCommand($phpspec . ' --format=junit --no-code-generation run');
|
||||
$output = $this->builder->getLastOutput();
|
||||
|
||||
chdir($curdir);
|
||||
chdir($currentDir);
|
||||
|
||||
/*
|
||||
* process xml output
|
||||
|
|
|
@ -93,9 +93,7 @@ class PhpUnit extends Plugin implements ZeroConfigPluginInterface
|
|||
return false;
|
||||
}
|
||||
|
||||
$cmd = $this->findBinary('phpunit');
|
||||
// run without logging
|
||||
$ret = null;
|
||||
$cmd = $this->findBinary('phpunit');
|
||||
$lastLine = exec($cmd.' --log-json . --version');
|
||||
if (false !== strpos($lastLine, '--log-json')) {
|
||||
$logFormat = 'junit'; // --log-json is not supported
|
||||
|
|
|
@ -12,7 +12,7 @@ use SensioLabs\Security\SecurityChecker as BaseSecurityChecker;
|
|||
|
||||
/**
|
||||
* SensioLabs Security Checker Plugin
|
||||
*
|
||||
*
|
||||
* @author Dmitry Khomutov <poisoncorpsee@gmail.com>
|
||||
*/
|
||||
class SecurityChecker extends Plugin implements ZeroConfigPluginInterface
|
||||
|
@ -20,8 +20,8 @@ class SecurityChecker extends Plugin implements ZeroConfigPluginInterface
|
|||
/**
|
||||
* @var integer
|
||||
*/
|
||||
protected $allowed_warnings;
|
||||
|
||||
protected $allowedWarnings;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
@ -37,14 +37,14 @@ class SecurityChecker extends Plugin implements ZeroConfigPluginInterface
|
|||
{
|
||||
parent::__construct($builder, $build, $options);
|
||||
|
||||
$this->allowed_warnings = 0;
|
||||
$this->allowedWarnings = 0;
|
||||
|
||||
if (isset($options['zero_config']) && $options['zero_config']) {
|
||||
$this->allowed_warnings = -1;
|
||||
$this->allowedWarnings = -1;
|
||||
}
|
||||
|
||||
if (array_key_exists('allowed_warnings', $options)) {
|
||||
$this->allowed_warnings = (int)$options['allowed_warnings'];
|
||||
$this->allowedWarnings = (int)$options['allowed_warnings'];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ class SecurityChecker extends Plugin implements ZeroConfigPluginInterface
|
|||
|
||||
if ($warnings) {
|
||||
foreach ($warnings as $library => $warning) {
|
||||
foreach ($warning['advisories'] as $advisory => $data) {
|
||||
foreach ($warning['advisories'] as $data) {
|
||||
$this->build->reportError(
|
||||
$this->builder,
|
||||
'security_checker',
|
||||
|
@ -88,7 +88,7 @@ class SecurityChecker extends Plugin implements ZeroConfigPluginInterface
|
|||
}
|
||||
}
|
||||
|
||||
if ($this->allowed_warnings != -1 && ((int)$checker->getLastVulnerabilityCount() > $this->allowed_warnings)) {
|
||||
if ($this->allowedWarnings != -1 && ((int)$checker->getLastVulnerabilityCount() > $this->allowedWarnings)) {
|
||||
$success = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ use Maknz\Slack\AttachmentField;
|
|||
|
||||
/**
|
||||
* Slack Plugin
|
||||
*
|
||||
*
|
||||
* @author Stephen Ball <phpci@stephen.rebelinblue.com>
|
||||
*/
|
||||
class SlackNotify extends Plugin
|
||||
|
@ -21,7 +21,7 @@ class SlackNotify extends Plugin
|
|||
private $username;
|
||||
private $message;
|
||||
private $icon;
|
||||
private $show_status;
|
||||
private $showStatus;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
|
@ -62,9 +62,9 @@ class SlackNotify extends Plugin
|
|||
}
|
||||
|
||||
if (isset($options['show_status'])) {
|
||||
$this->show_status = (bool) $options['show_status'];
|
||||
$this->showStatus = (bool) $options['show_status'];
|
||||
} else {
|
||||
$this->show_status = true;
|
||||
$this->showStatus = true;
|
||||
}
|
||||
|
||||
if (isset($options['icon'])) {
|
||||
|
@ -100,7 +100,7 @@ class SlackNotify extends Plugin
|
|||
}
|
||||
|
||||
// Include an attachment which shows the status and hide the message
|
||||
if ($this->show_status) {
|
||||
if ($this->showStatus) {
|
||||
$successfulBuild = $this->build->isSuccessful();
|
||||
|
||||
if ($successfulBuild) {
|
||||
|
|
|
@ -28,7 +28,7 @@ class TechnicalDebt extends Plugin implements ZeroConfigPluginInterface
|
|||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $allowed_errors;
|
||||
protected $allowedErrors;
|
||||
|
||||
/**
|
||||
* @var array - paths to ignore
|
||||
|
@ -123,7 +123,7 @@ class TechnicalDebt extends Plugin implements ZeroConfigPluginInterface
|
|||
$this->suffixes = ['php'];
|
||||
$this->directory = $this->builder->buildPath;
|
||||
$this->ignore = $this->builder->ignore;
|
||||
$this->allowed_errors = 0;
|
||||
$this->allowedErrors = 0;
|
||||
$this->searches = ['TODO', 'FIXME', 'TO DO', 'FIX ME'];
|
||||
|
||||
if (!empty($options['suffixes']) && is_array($options['suffixes'])) {
|
||||
|
@ -135,7 +135,7 @@ class TechnicalDebt extends Plugin implements ZeroConfigPluginInterface
|
|||
}
|
||||
|
||||
if (isset($options['zero_config']) && $options['zero_config']) {
|
||||
$this->allowed_errors = -1;
|
||||
$this->allowedErrors = -1;
|
||||
}
|
||||
|
||||
$this->setOptions($options);
|
||||
|
@ -185,7 +185,7 @@ class TechnicalDebt extends Plugin implements ZeroConfigPluginInterface
|
|||
|
||||
$this->build->storeMeta('technical_debt-warnings', $errorCount);
|
||||
|
||||
if ($this->allowed_errors !== -1 && $errorCount > $this->allowed_errors) {
|
||||
if ($this->allowedErrors !== -1 && $errorCount > $this->allowedErrors) {
|
||||
$success = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use PHPCensor\Plugin;
|
|||
|
||||
/**
|
||||
* XMPP Notification - Send notification for successful or failure build
|
||||
*
|
||||
*
|
||||
* @author Alexandre Russo <dev.github@ange7.com>
|
||||
*/
|
||||
class XMPP extends Plugin
|
||||
|
@ -48,7 +48,7 @@ class XMPP extends Plugin
|
|||
/**
|
||||
* @var string, mask to format date
|
||||
*/
|
||||
protected $date_format;
|
||||
protected $dateFormat;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
|
@ -57,7 +57,7 @@ class XMPP extends Plugin
|
|||
{
|
||||
return 'xmpp';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -71,7 +71,7 @@ class XMPP extends Plugin
|
|||
$this->alias = '';
|
||||
$this->recipients = [];
|
||||
$this->tls = false;
|
||||
$this->date_format = '%c';
|
||||
$this->dateFormat = '%c';
|
||||
|
||||
/*
|
||||
* Set recipients list
|
||||
|
@ -189,7 +189,7 @@ class XMPP extends Plugin
|
|||
$message = "✘ [".$this->build->getProjectTitle()."] Build #" . $this->build->getId()." failure";
|
||||
}
|
||||
|
||||
$message .= ' ('.strftime($this->date_format).')';
|
||||
$message .= ' ('.strftime($this->dateFormat).')';
|
||||
|
||||
return file_put_contents($message_file, $message);
|
||||
}
|
||||
|
|
|
@ -274,8 +274,8 @@ class BuildStore extends Store
|
|||
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
$projects = [];
|
||||
$latest = [];
|
||||
foreach($res as $item) {
|
||||
$latest = [];
|
||||
foreach ($res as $item) {
|
||||
$project_id = $item['project_id'];
|
||||
$environment = $item['environment'];
|
||||
if (empty($projects[$project_id])) {
|
||||
|
@ -312,11 +312,13 @@ class BuildStore extends Store
|
|||
$projects[$project_id][$environment]['failed'] = $build;
|
||||
}
|
||||
}
|
||||
foreach($projects as $idx => $project) {
|
||||
|
||||
foreach ($projects as $idx => $project) {
|
||||
$projects[$idx] = array_filter($project, function($val) {
|
||||
return ($val['latest'][0]->getStatus() != Build::STATUS_SUCCESS);
|
||||
});
|
||||
}
|
||||
|
||||
$projects = array_filter($projects);
|
||||
|
||||
return ['projects' => $projects, 'latest' => $latest];
|
||||
|
|
|
@ -80,6 +80,30 @@ EOD;
|
|||
public function testFindBinary_ReturnsNullWihQuietArgument()
|
||||
{
|
||||
$thisFileName = "WorldWidePeace";
|
||||
$this->assertNull($this->testedExecutor->findBinary($thisFileName, true));
|
||||
$this->assertFalse($this->testedExecutor->findBinary($thisFileName, true));
|
||||
}
|
||||
|
||||
public function testReplaceIllegalCharacters()
|
||||
{
|
||||
$this->assertEquals(
|
||||
\Normalizer::normalize("start <20> end"),
|
||||
\Normalizer::normalize($this->testedExecutor->replaceIllegalCharacters(
|
||||
"start \xf0\x9c\x83\x96 end"
|
||||
))
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
\Normalizer::normalize("start <20> end"),
|
||||
\Normalizer::normalize($this->testedExecutor->replaceIllegalCharacters(
|
||||
"start \xF0\x9C\x83\x96 end"
|
||||
))
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
\Normalizer::normalize("start 123_X08<30>_X00<30>_Xa<58>_5432 end"),
|
||||
\Normalizer::normalize($this->testedExecutor->replaceIllegalCharacters(
|
||||
"start 123_X08\x08_X00\x00_Xa4\xa4_5432 end"
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue