Removed base models and stores

This commit is contained in:
Dmitry Khomutov 2017-02-16 19:45:50 +07:00
parent 9f0580e802
commit 96aa345dc0
No known key found for this signature in database
GPG key ID: 7EB36C9576F9ECB9
26 changed files with 3248 additions and 3665 deletions

View file

@ -1,629 +0,0 @@
<?php
/**
* Build base model for table: build
*/
namespace PHPCensor\Model\Base;
use PHPCensor\Model;
use b8\Store\Factory;
use PHPCensor\Model\Project;
/**
* Build Base Model
*/
class BuildBase extends Model
{
/**
* @var array
*/
public static $sleepable = [];
/**
* @var string
*/
protected $tableName = 'build';
/**
* @var string
*/
protected $modelName = 'Build';
/**
* @var array
*/
protected $data = [
'id' => null,
'project_id' => null,
'commit_id' => null,
'status' => null,
'log' => null,
'branch' => null,
'created' => null,
'started' => null,
'finished' => null,
'committer_email' => null,
'commit_message' => null,
'extra' => null,
];
/**
* @var array
*/
protected $getters = [
// Direct property getters:
'id' => 'getId',
'project_id' => 'getProjectId',
'commit_id' => 'getCommitId',
'status' => 'getStatus',
'log' => 'getLog',
'branch' => 'getBranch',
'created' => 'getCreated',
'started' => 'getStarted',
'finished' => 'getFinished',
'committer_email' => 'getCommitterEmail',
'commit_message' => 'getCommitMessage',
'extra' => 'getExtra',
// Foreign key getters:
'Project' => 'getProject',
];
/**
* @var array
*/
protected $setters = [
// Direct property setters:
'id' => 'setId',
'project_id' => 'setProjectId',
'commit_id' => 'setCommitId',
'status' => 'setStatus',
'log' => 'setLog',
'branch' => 'setBranch',
'created' => 'setCreated',
'started' => 'setStarted',
'finished' => 'setFinished',
'committer_email' => 'setCommitterEmail',
'commit_message' => 'setCommitMessage',
'extra' => 'setExtra',
// Foreign key setters:
'Project' => 'setProject',
];
/**
* @var array
*/
public $columns = [
'id' => [
'type' => 'int',
'length' => 11,
'primary_key' => true,
'auto_increment' => true,
'default' => null,
],
'project_id' => [
'type' => 'int',
'length' => 11,
'default' => null,
],
'commit_id' => [
'type' => 'varchar',
'length' => 50,
'default' => null,
],
'status' => [
'type' => 'int',
'length' => 11,
'default' => null,
],
'log' => [
'type' => 'mediumtext',
'nullable' => true,
'default' => null,
],
'branch' => [
'type' => 'varchar',
'length' => 250,
'default' => 'master',
],
'created' => [
'type' => 'datetime',
'nullable' => true,
'default' => null,
],
'started' => [
'type' => 'datetime',
'nullable' => true,
'default' => null,
],
'finished' => [
'type' => 'datetime',
'nullable' => true,
'default' => null,
],
'committer_email' => [
'type' => 'varchar',
'length' => 512,
'nullable' => true,
'default' => null,
],
'commit_message' => [
'type' => 'text',
'nullable' => true,
'default' => null,
],
'extra' => [
'type' => 'text',
'nullable' => true,
'default' => null,
],
];
/**
* @var array
*/
public $indexes = [
'PRIMARY' => ['unique' => true, 'columns' => 'id'],
'project_id' => ['columns' => 'project_id'],
'idx_status' => ['columns' => 'status'],
];
/**
* @var array
*/
public $foreignKeys = [
'build_ibfk_1' => [
'local_col' => 'project_id',
'update' => 'CASCADE',
'delete' => 'CASCADE',
'table' => 'project',
'col' => 'id'
],
];
/**
* Get the value of Id / id.
*
* @return int
*/
public function getId()
{
$rtn = $this->data['id'];
return $rtn;
}
/**
* Get the value of ProjectId / project_id.
*
* @return int
*/
public function getProjectId()
{
$rtn = $this->data['project_id'];
return $rtn;
}
/**
* Get the value of CommitId / commit_id.
*
* @return string
*/
public function getCommitId()
{
$rtn = $this->data['commit_id'];
return $rtn;
}
/**
* Get the value of Status / status.
*
* @return int
*/
public function getStatus()
{
$rtn = $this->data['status'];
return $rtn;
}
/**
* Get the value of Log / log.
*
* @return string
*/
public function getLog()
{
$rtn = $this->data['log'];
return $rtn;
}
/**
* Get the value of Branch / branch.
*
* @return string
*/
public function getBranch()
{
$rtn = $this->data['branch'];
return $rtn;
}
/**
* Get the value of Created / created.
*
* @return \DateTime
*/
public function getCreated()
{
$rtn = $this->data['created'];
if (!empty($rtn)) {
$rtn = new \DateTime($rtn);
}
return $rtn;
}
/**
* Get the value of Started / started.
*
* @return \DateTime
*/
public function getStarted()
{
$rtn = $this->data['started'];
if (!empty($rtn)) {
$rtn = new \DateTime($rtn);
}
return $rtn;
}
/**
* Get the value of Finished / finished.
*
* @return \DateTime
*/
public function getFinished()
{
$rtn = $this->data['finished'];
if (!empty($rtn)) {
$rtn = new \DateTime($rtn);
}
return $rtn;
}
/**
* Get the value of CommitterEmail / committer_email.
*
* @return string
*/
public function getCommitterEmail()
{
$rtn = $this->data['committer_email'];
return $rtn;
}
/**
* Get the value of CommitMessage / commit_message.
*
* @return string
*/
public function getCommitMessage()
{
$rtn = $this->data['commit_message'];
return $rtn;
}
/**
* Get the value of Extra / extra.
*
* @return string
*/
public function getExtra()
{
$rtn = $this->data['extra'];
return $rtn;
}
/**
* Set the value of Id / id. Must not be null.
*
* @param $value int
*/
public function setId($value)
{
$this->validateNotNull('Id', $value);
$this->validateInt('Id', $value);
if ($this->data['id'] === $value) {
return;
}
$this->data['id'] = $value;
$this->setModified('id');
}
/**
* Set the value of ProjectId / project_id. Must not be null.
*
* @param $value int
*/
public function setProjectId($value)
{
$this->validateNotNull('ProjectId', $value);
$this->validateInt('ProjectId', $value);
if ($this->data['project_id'] === $value) {
return;
}
$this->data['project_id'] = $value;
$this->setModified('project_id');
}
/**
* Set the value of CommitId / commit_id. Must not be null.
*
* @param $value string
*/
public function setCommitId($value)
{
$this->validateNotNull('CommitId', $value);
$this->validateString('CommitId', $value);
if ($this->data['commit_id'] === $value) {
return;
}
$this->data['commit_id'] = $value;
$this->setModified('commit_id');
}
/**
* Set the value of Status / status. Must not be null.
*
* @param $value int
*/
public function setStatus($value)
{
$this->validateNotNull('Status', $value);
$this->validateInt('Status', $value);
if ($this->data['status'] === $value) {
return;
}
$this->data['status'] = $value;
$this->setModified('status');
}
/**
* Set the value of Log / log.
*
* @param $value string
*/
public function setLog($value)
{
$this->validateString('Log', $value);
if ($this->data['log'] === $value) {
return;
}
$this->data['log'] = $value;
$this->setModified('log');
}
/**
* Set the value of Branch / branch. Must not be null.
*
* @param $value string
*/
public function setBranch($value)
{
$this->validateNotNull('Branch', $value);
$this->validateString('Branch', $value);
if ($this->data['branch'] === $value) {
return;
}
$this->data['branch'] = $value;
$this->setModified('branch');
}
/**
* Set the value of Created / created.
*
* @param $value \DateTime
*/
public function setCreated($value)
{
$this->validateDate('Created', $value);
if ($this->data['created'] === $value) {
return;
}
$this->data['created'] = $value;
$this->setModified('created');
}
/**
* Set the value of Started / started.
*
* @param $value \DateTime
*/
public function setStarted($value)
{
$this->validateDate('Started', $value);
if ($this->data['started'] === $value) {
return;
}
$this->data['started'] = $value;
$this->setModified('started');
}
/**
* Set the value of Finished / finished.
*
* @param $value \DateTime
*/
public function setFinished($value)
{
$this->validateDate('Finished', $value);
if ($this->data['finished'] === $value) {
return;
}
$this->data['finished'] = $value;
$this->setModified('finished');
}
/**
* Set the value of CommitterEmail / committer_email.
*
* @param $value string
*/
public function setCommitterEmail($value)
{
$this->validateString('CommitterEmail', $value);
if ($this->data['committer_email'] === $value) {
return;
}
$this->data['committer_email'] = $value;
$this->setModified('committer_email');
}
/**
* Set the value of CommitMessage / commit_message.
*
* @param $value string
*/
public function setCommitMessage($value)
{
$this->validateString('CommitMessage', $value);
if ($this->data['commit_message'] === $value) {
return;
}
$this->data['commit_message'] = $value;
$this->setModified('commit_message');
}
/**
* Set the value of Extra / extra.
*
* @param $value string
*/
public function setExtra($value)
{
$this->validateString('Extra', $value);
if ($this->data['extra'] === $value) {
return;
}
$this->data['extra'] = $value;
$this->setModified('extra');
}
/**
* Get the Project model for this Build by Id.
*
* @return \PHPCensor\Model\Project
*/
public function getProject()
{
$key = $this->getProjectId();
if (empty($key)) {
return null;
}
return Factory::getStore('Project', 'PHPCensor')->getById($key);
}
/**
* Set Project - Accepts an ID, an array representing a Project or a Project model.
*
* @param $value mixed
*/
public function setProject($value)
{
// Is this an instance of Project?
if ($value instanceof Project) {
return $this->setProjectObject($value);
}
// Is this an array representing a Project item?
if (is_array($value) && !empty($value['id'])) {
return $this->setProjectId($value['id']);
}
// Is this a scalar value representing the ID of this foreign key?
return $this->setProjectId($value);
}
/**
* Set Project - Accepts a Project model.
*
* @param $value Project
*/
public function setProjectObject(Project $value)
{
return $this->setProjectId($value->getId());
}
/**
* Get BuildError models by BuildId for this Build.
*
* @return \PHPCensor\Model\BuildError[]
*/
public function getBuildBuildErrors()
{
return Factory::getStore('BuildError', 'PHPCensor')->getByBuildId($this->getId());
}
/**
* Get BuildMeta models by BuildId for this Build.
*
* @return \PHPCensor\Model\BuildMeta[]
*/
public function getBuildBuildMetas()
{
return Factory::getStore('BuildMeta', 'PHPCensor')->getByBuildId($this->getId());
}
}

View file

@ -1,504 +0,0 @@
<?php
/**
* BuildError base model for table: build_error
*/
namespace PHPCensor\Model\Base;
use PHPCensor\Model;
use b8\Store\Factory;
use PHPCensor\Model\Build;
/**
* BuildError Base Model
*/
class BuildErrorBase extends Model
{
/**
* @var array
*/
public static $sleepable = [];
/**
* @var string
*/
protected $tableName = 'build_error';
/**
* @var string
*/
protected $modelName = 'BuildError';
/**
* @var array
*/
protected $data = [
'id' => null,
'build_id' => null,
'plugin' => null,
'file' => null,
'line_start' => null,
'line_end' => null,
'severity' => null,
'message' => null,
'created_date' => null,
];
/**
* @var array
*/
protected $getters = [
// Direct property getters:
'id' => 'getId',
'build_id' => 'getBuildId',
'plugin' => 'getPlugin',
'file' => 'getFile',
'line_start' => 'getLineStart',
'line_end' => 'getLineEnd',
'severity' => 'getSeverity',
'message' => 'getMessage',
'created_date' => 'getCreatedDate',
// Foreign key getters:
'Build' => 'getBuild',
];
/**
* @var array
*/
protected $setters = [
// Direct property setters:
'id' => 'setId',
'build_id' => 'setBuildId',
'plugin' => 'setPlugin',
'file' => 'setFile',
'line_start' => 'setLineStart',
'line_end' => 'setLineEnd',
'severity' => 'setSeverity',
'message' => 'setMessage',
'created_date' => 'setCreatedDate',
// Foreign key setters:
'Build' => 'setBuild',
];
/**
* @var array
*/
public $columns = [
'id' => [
'type' => 'int',
'length' => 11,
'primary_key' => true,
'auto_increment' => true,
'default' => null,
],
'build_id' => [
'type' => 'int',
'length' => 11,
'default' => null,
],
'plugin' => [
'type' => 'varchar',
'length' => 100,
'default' => null,
],
'file' => [
'type' => 'varchar',
'length' => 250,
'nullable' => true,
'default' => null,
],
'line_start' => [
'type' => 'int',
'length' => 11,
'nullable' => true,
'default' => null,
],
'line_end' => [
'type' => 'int',
'length' => 11,
'nullable' => true,
'default' => null,
],
'severity' => [
'type' => 'tinyint',
'length' => 3,
'default' => null,
],
'message' => [
'type' => 'varchar',
'length' => 250,
'default' => null,
],
'created_date' => [
'type' => 'datetime',
'default' => null,
],
];
/**
* @var array
*/
public $indexes = [
'PRIMARY' => ['unique' => true, 'columns' => 'id'],
'build_id' => ['columns' => 'build_id, created_date'],
];
/**
* @var array
*/
public $foreignKeys = [
'build_error_ibfk_1' => [
'local_col' => 'build_id',
'update' => 'CASCADE',
'delete' => 'CASCADE',
'table' => 'build',
'col' => 'id'
],
];
/**
* Get the value of Id / id.
*
* @return int
*/
public function getId()
{
$rtn = $this->data['id'];
return $rtn;
}
/**
* Get the value of BuildId / build_id.
*
* @return int
*/
public function getBuildId()
{
$rtn = $this->data['build_id'];
return $rtn;
}
/**
* Get the value of Plugin / plugin.
*
* @return string
*/
public function getPlugin()
{
$rtn = $this->data['plugin'];
return $rtn;
}
/**
* Get the value of File / file.
*
* @return string
*/
public function getFile()
{
$rtn = $this->data['file'];
return $rtn;
}
/**
* Get the value of LineStart / line_start.
*
* @return int
*/
public function getLineStart()
{
$rtn = $this->data['line_start'];
return $rtn;
}
/**
* Get the value of LineEnd / line_end.
*
* @return int
*/
public function getLineEnd()
{
$rtn = $this->data['line_end'];
return $rtn;
}
/**
* Get the value of Severity / severity.
*
* @return int
*/
public function getSeverity()
{
$rtn = $this->data['severity'];
return $rtn;
}
/**
* Get the value of Message / message.
*
* @return string
*/
public function getMessage()
{
$rtn = $this->data['message'];
return $rtn;
}
/**
* Get the value of CreatedDate / created_date.
*
* @return \DateTime
*/
public function getCreatedDate()
{
$rtn = $this->data['created_date'];
if (!empty($rtn)) {
$rtn = new \DateTime($rtn);
}
return $rtn;
}
/**
* Set the value of Id / id.
*
* Must not be null.
* @param $value int
*/
public function setId($value)
{
$this->validateNotNull('Id', $value);
$this->validateInt('Id', $value);
if ($this->data['id'] === $value) {
return;
}
$this->data['id'] = $value;
$this->setModified('id');
}
/**
* Set the value of BuildId / build_id.
*
* Must not be null.
* @param $value int
*/
public function setBuildId($value)
{
$this->validateNotNull('BuildId', $value);
$this->validateInt('BuildId', $value);
if ($this->data['build_id'] === $value) {
return;
}
$this->data['build_id'] = $value;
$this->setModified('build_id');
}
/**
* Set the value of Plugin / plugin.
*
* Must not be null.
* @param $value string
*/
public function setPlugin($value)
{
$this->validateNotNull('Plugin', $value);
$this->validateString('Plugin', $value);
if ($this->data['plugin'] === $value) {
return;
}
$this->data['plugin'] = $value;
$this->setModified('plugin');
}
/**
* Set the value of File / file.
*
* @param $value string
*/
public function setFile($value)
{
$this->validateString('File', $value);
if ($this->data['file'] === $value) {
return;
}
$this->data['file'] = $value;
$this->setModified('file');
}
/**
* Set the value of LineStart / line_start.
*
* @param $value int
*/
public function setLineStart($value)
{
$this->validateInt('LineStart', $value);
if ($this->data['line_start'] === $value) {
return;
}
$this->data['line_start'] = $value;
$this->setModified('line_start');
}
/**
* Set the value of LineEnd / line_end.
*
* @param $value int
*/
public function setLineEnd($value)
{
$this->validateInt('LineEnd', $value);
if ($this->data['line_end'] === $value) {
return;
}
$this->data['line_end'] = $value;
$this->setModified('line_end');
}
/**
* Set the value of Severity / severity.
*
* Must not be null.
* @param $value int
*/
public function setSeverity($value)
{
$this->validateNotNull('Severity', $value);
$this->validateInt('Severity', $value);
if ($this->data['severity'] === $value) {
return;
}
$this->data['severity'] = $value;
$this->setModified('severity');
}
/**
* Set the value of Message / message.
*
* Must not be null.
* @param $value string
*/
public function setMessage($value)
{
$this->validateNotNull('Message', $value);
$this->validateString('Message', $value);
if ($this->data['message'] === $value) {
return;
}
$this->data['message'] = $value;
$this->setModified('message');
}
/**
* Set the value of CreatedDate / created_date.
*
* Must not be null.
* @param $value \DateTime
*/
public function setCreatedDate($value)
{
$this->validateNotNull('CreatedDate', $value);
$this->validateDate('CreatedDate', $value);
if ($this->data['created_date'] === $value) {
return;
}
$this->data['created_date'] = $value;
$this->setModified('created_date');
}
/**
* Get the Build model for this BuildError by Id.
*
* @uses \PHPCensor\Store\BuildStore::getById()
* @uses \PHPCensor\Model\Build
* @return \PHPCensor\Model\Build
*/
public function getBuild()
{
$key = $this->getBuildId();
if (empty($key)) {
return null;
}
$cacheKey = 'Cache.Build.' . $key;
$rtn = $this->cache->get($cacheKey, null);
if (empty($rtn)) {
$rtn = Factory::getStore('Build', 'PHPCensor')->getById($key);
$this->cache->set($cacheKey, $rtn);
}
return $rtn;
}
/**
* Set Build - Accepts an ID, an array representing a Build or a Build model.
*
* @param $value mixed
*/
public function setBuild($value)
{
// Is this an instance of Build?
if ($value instanceof Build) {
return $this->setBuildObject($value);
}
// Is this an array representing a Build item?
if (is_array($value) && !empty($value['id'])) {
return $this->setBuildId($value['id']);
}
// Is this a scalar value representing the ID of this foreign key?
return $this->setBuildId($value);
}
/**
* Set Build - Accepts a Build model.
*
* @param $value Build
*/
public function setBuildObject(Build $value)
{
return $this->setBuildId($value->getId());
}
}

View file

@ -1,409 +0,0 @@
<?php
/**
* BuildMeta base model for table: build_meta
*/
namespace PHPCensor\Model\Base;
use PHPCensor\Model;
use b8\Store\Factory;
use PHPCensor\Model\Project;
use PHPCensor\Model\Build;
/**
* BuildMeta Base Model
*/
class BuildMetaBase extends Model
{
/**
* @var array
*/
public static $sleepable = [];
/**
* @var string
*/
protected $tableName = 'build_meta';
/**
* @var string
*/
protected $modelName = 'BuildMeta';
/**
* @var array
*/
protected $data = [
'id' => null,
'project_id' => null,
'build_id' => null,
'meta_key' => null,
'meta_value' => null,
];
/**
* @var array
*/
protected $getters = [
// Direct property getters:
'id' => 'getId',
'project_id' => 'getProjectId',
'build_id' => 'getBuildId',
'meta_key' => 'getMetaKey',
'meta_value' => 'getMetaValue',
// Foreign key getters:
'Project' => 'getProject',
'Build' => 'getBuild',
];
/**
* @var array
*/
protected $setters = [
// Direct property setters:
'id' => 'setId',
'project_id' => 'setProjectId',
'build_id' => 'setBuildId',
'meta_key' => 'setMetaKey',
'meta_value' => 'setMetaValue',
// Foreign key setters:
'Project' => 'setProject',
'Build' => 'setBuild',
];
/**
* @var array
*/
public $columns = [
'id' => [
'type' => 'int',
'length' => 10,
'primary_key' => true,
'auto_increment' => true,
'default' => null,
],
'project_id' => [
'type' => 'int',
'length' => 11,
'default' => null,
],
'build_id' => [
'type' => 'int',
'length' => 11,
'default' => null,
],
'meta_key' => [
'type' => 'varchar',
'length' => 250,
'default' => null,
],
'meta_value' => [
'type' => 'mediumtext',
'default' => null,
],
];
/**
* @var array
*/
public $indexes = [
'PRIMARY' => ['unique' => true, 'columns' => 'id'],
'idx_meta_id' => ['unique' => true, 'columns' => 'build_id, meta_key'],
'project_id' => ['columns' => 'project_id'],
];
/**
* @var array
*/
public $foreignKeys = [
'build_meta_ibfk_1' => [
'local_col' => 'project_id',
'update' => 'CASCADE',
'delete' => 'CASCADE',
'table' => 'project',
'col' => 'id'
],
'fk_meta_build_id' => [
'local_col' => 'build_id',
'update' => 'CASCADE',
'delete' => 'CASCADE',
'table' => 'build',
'col' => 'id'
],
];
/**
* Get the value of Id / id.
*
* @return int
*/
public function getId()
{
$rtn = $this->data['id'];
return $rtn;
}
/**
* Get the value of ProjectId / project_id.
*
* @return int
*/
public function getProjectId()
{
$rtn = $this->data['project_id'];
return $rtn;
}
/**
* Get the value of BuildId / build_id.
*
* @return int
*/
public function getBuildId()
{
$rtn = $this->data['build_id'];
return $rtn;
}
/**
* Get the value of MetaKey / meta_key.
*
* @return string
*/
public function getMetaKey()
{
$rtn = $this->data['meta_key'];
return $rtn;
}
/**
* Get the value of MetaValue / meta_value.
*
* @return string
*/
public function getMetaValue()
{
$rtn = $this->data['meta_value'];
return $rtn;
}
/**
* Set the value of Id / id.
*
* Must not be null.
* @param $value int
*/
public function setId($value)
{
$this->validateNotNull('Id', $value);
$this->validateInt('Id', $value);
if ($this->data['id'] === $value) {
return;
}
$this->data['id'] = $value;
$this->setModified('id');
}
/**
* Set the value of ProjectId / project_id.
*
* Must not be null.
* @param $value int
*/
public function setProjectId($value)
{
$this->validateNotNull('ProjectId', $value);
$this->validateInt('ProjectId', $value);
if ($this->data['project_id'] === $value) {
return;
}
$this->data['project_id'] = $value;
$this->setModified('project_id');
}
/**
* Set the value of BuildId / build_id.
*
* Must not be null.
* @param $value int
*/
public function setBuildId($value)
{
$this->validateNotNull('BuildId', $value);
$this->validateInt('BuildId', $value);
if ($this->data['build_id'] === $value) {
return;
}
$this->data['build_id'] = $value;
$this->setModified('build_id');
}
/**
* Set the value of MetaKey / meta_key.
*
* Must not be null.
* @param $value string
*/
public function setMetaKey($value)
{
$this->validateNotNull('MetaKey', $value);
$this->validateString('MetaKey', $value);
if ($this->data['meta_key'] === $value) {
return;
}
$this->data['meta_key'] = $value;
$this->setModified('meta_key');
}
/**
* Set the value of MetaValue / meta_value.
*
* Must not be null.
* @param $value string
*/
public function setMetaValue($value)
{
$this->validateNotNull('MetaValue', $value);
$this->validateString('MetaValue', $value);
if ($this->data['meta_value'] === $value) {
return;
}
$this->data['meta_value'] = $value;
$this->setModified('meta_value');
}
/**
* Get the Project model for this BuildMeta by Id.
*
* @uses \PHPCensor\Store\ProjectStore::getById()
* @uses \PHPCensor\Model\Project
* @return \PHPCensor\Model\Project
*/
public function getProject()
{
$key = $this->getProjectId();
if (empty($key)) {
return null;
}
$cacheKey = 'Cache.Project.' . $key;
$rtn = $this->cache->get($cacheKey, null);
if (empty($rtn)) {
$rtn = Factory::getStore('Project', 'PHPCensor')->getById($key);
$this->cache->set($cacheKey, $rtn);
}
return $rtn;
}
/**
* Set Project - Accepts an ID, an array representing a Project or a Project model.
*
* @param $value mixed
*/
public function setProject($value)
{
// Is this an instance of Project?
if ($value instanceof Project) {
return $this->setProjectObject($value);
}
// Is this an array representing a Project item?
if (is_array($value) && !empty($value['id'])) {
return $this->setProjectId($value['id']);
}
// Is this a scalar value representing the ID of this foreign key?
return $this->setProjectId($value);
}
/**
* Set Project - Accepts a Project model.
*
* @param $value Project
*/
public function setProjectObject(Project $value)
{
return $this->setProjectId($value->getId());
}
/**
* Get the Build model for this BuildMeta by Id.
*
* @uses \PHPCensor\Store\BuildStore::getById()
* @uses \PHPCensor\Model\Build
* @return \PHPCensor\Model\Build
*/
public function getBuild()
{
$key = $this->getBuildId();
if (empty($key)) {
return null;
}
$cacheKey = 'Cache.Build.' . $key;
$rtn = $this->cache->get($cacheKey, null);
if (empty($rtn)) {
$rtn = Factory::getStore('Build', 'PHPCensor')->getById($key);
$this->cache->set($cacheKey, $rtn);
}
return $rtn;
}
/**
* Set Build - Accepts an ID, an array representing a Build or a Build model.
*
* @param $value mixed
*/
public function setBuild($value)
{
// Is this an instance of Build?
if ($value instanceof Build) {
return $this->setBuildObject($value);
}
// Is this an array representing a Build item?
if (is_array($value) && !empty($value['id'])) {
return $this->setBuildId($value['id']);
}
// Is this a scalar value representing the ID of this foreign key?
return $this->setBuildId($value);
}
/**
* Set Build - Accepts a Build model.
*
* @param $value Build
*/
public function setBuildObject(Build $value)
{
return $this->setBuildId($value->getId());
}
}

View file

@ -1,678 +0,0 @@
<?php
/**
* Project base model for table: project
*/
namespace PHPCensor\Model\Base;
use PHPCensor\Model;
use b8\Store\Factory;
use PHPCensor\Model\ProjectGroup;
/**
* Project Base Model
*/
class ProjectBase extends Model
{
/**
* @var array
*/
public static $sleepable = [];
/**
* @var string
*/
protected $tableName = 'project';
/**
* @var string
*/
protected $modelName = 'Project';
/**
* @var array
*/
protected $data = [
'id' => null,
'title' => null,
'reference' => null,
'branch' => null,
'ssh_private_key' => null,
'type' => null,
'access_information' => null,
'last_commit' => null,
'build_config' => null,
'ssh_public_key' => null,
'allow_public_status' => null,
'archived' => null,
'group_id' => null,
];
/**
* @var array
*/
protected $getters = [
// Direct property getters:
'id' => 'getId',
'title' => 'getTitle',
'reference' => 'getReference',
'branch' => 'getBranch',
'ssh_private_key' => 'getSshPrivateKey',
'type' => 'getType',
'access_information' => 'getAccessInformation',
'last_commit' => 'getLastCommit',
'build_config' => 'getBuildConfig',
'ssh_public_key' => 'getSshPublicKey',
'allow_public_status' => 'getAllowPublicStatus',
'archived' => 'getArchived',
'group_id' => 'getGroupId',
// Foreign key getters:
'Group' => 'getGroup',
];
/**
* @var array
*/
protected $setters = [
// Direct property setters:
'id' => 'setId',
'title' => 'setTitle',
'reference' => 'setReference',
'branch' => 'setBranch',
'ssh_private_key' => 'setSshPrivateKey',
'type' => 'setType',
'access_information' => 'setAccessInformation',
'last_commit' => 'setLastCommit',
'build_config' => 'setBuildConfig',
'ssh_public_key' => 'setSshPublicKey',
'allow_public_status' => 'setAllowPublicStatus',
'archived' => 'setArchived',
'group_id' => 'setGroupId',
// Foreign key setters:
'Group' => 'setGroup',
];
/**
* @var array
*/
public $columns = [
'id' => [
'type' => 'int',
'length' => 11,
'primary_key' => true,
'auto_increment' => true,
'default' => null,
],
'title' => [
'type' => 'varchar',
'length' => 250,
'default' => null,
],
'reference' => [
'type' => 'varchar',
'length' => 250,
'default' => null,
],
'branch' => [
'type' => 'varchar',
'length' => 250,
'default' => 'master',
],
'ssh_private_key' => [
'type' => 'text',
'nullable' => true,
'default' => null,
],
'type' => [
'type' => 'varchar',
'length' => 50,
'default' => null,
],
'access_information' => [
'type' => 'varchar',
'length' => 250,
'nullable' => true,
'default' => null,
],
'last_commit' => [
'type' => 'varchar',
'length' => 250,
'nullable' => true,
'default' => null,
],
'build_config' => [
'type' => 'text',
'nullable' => true,
'default' => null,
],
'ssh_public_key' => [
'type' => 'text',
'nullable' => true,
'default' => null,
],
'allow_public_status' => [
'type' => 'int',
'length' => 11,
],
'archived' => [
'type' => 'tinyint',
'length' => 1,
'default' => null,
],
'group_id' => [
'type' => 'int',
'length' => 11,
'default' => 1,
],
];
/**
* @var array
*/
public $indexes = [
'PRIMARY' => ['unique' => true, 'columns' => 'id'],
'idx_project_title' => ['columns' => 'title'],
'group_id' => ['columns' => 'group_id'],
];
/**
* @var array
*/
public $foreignKeys = [
'project_ibfk_1' => [
'local_col' => 'group_id',
'update' => 'CASCADE',
'delete' => '',
'table' => 'project_group',
'col' => 'id'
],
];
/**
* Get the value of Id / id.
*
* @return int
*/
public function getId()
{
$rtn = $this->data['id'];
return $rtn;
}
/**
* Get the value of Title / title.
*
* @return string
*/
public function getTitle()
{
$rtn = $this->data['title'];
return $rtn;
}
/**
* Get the value of Reference / reference.
*
* @return string
*/
public function getReference()
{
$rtn = $this->data['reference'];
return $rtn;
}
/**
* Get the value of Branch / branch.
*
* @return string
*/
public function getBranch()
{
$rtn = $this->data['branch'];
return $rtn;
}
/**
* Get the value of SshPrivateKey / ssh_private_key.
*
* @return string
*/
public function getSshPrivateKey()
{
$rtn = $this->data['ssh_private_key'];
return $rtn;
}
/**
* Get the value of Type / type.
*
* @return string
*/
public function getType()
{
$rtn = $this->data['type'];
return $rtn;
}
/**
* Get the value of AccessInformation / access_information.
*
* @return string
*/
public function getAccessInformation()
{
$rtn = $this->data['access_information'];
return $rtn;
}
/**
* Get the value of LastCommit / last_commit.
*
* @return string
*/
public function getLastCommit()
{
$rtn = $this->data['last_commit'];
return $rtn;
}
/**
* Get the value of BuildConfig / build_config.
*
* @return string
*/
public function getBuildConfig()
{
$rtn = $this->data['build_config'];
return $rtn;
}
/**
* Get the value of SshPublicKey / ssh_public_key.
*
* @return string
*/
public function getSshPublicKey()
{
$rtn = $this->data['ssh_public_key'];
return $rtn;
}
/**
* Get the value of AllowPublicStatus / allow_public_status.
*
* @return int
*/
public function getAllowPublicStatus()
{
$rtn = $this->data['allow_public_status'];
return $rtn;
}
/**
* Get the value of Archived / archived.
*
* @return int
*/
public function getArchived()
{
$rtn = $this->data['archived'];
return $rtn;
}
/**
* Get the value of GroupId / group_id.
*
* @return int
*/
public function getGroupId()
{
$rtn = $this->data['group_id'];
return $rtn;
}
/**
* Set the value of Id / id.
*
* Must not be null.
* @param $value int
*/
public function setId($value)
{
$this->validateNotNull('Id', $value);
$this->validateInt('Id', $value);
if ($this->data['id'] === $value) {
return;
}
$this->data['id'] = $value;
$this->setModified('id');
}
/**
* Set the value of Title / title.
*
* Must not be null.
* @param $value string
*/
public function setTitle($value)
{
$this->validateNotNull('Title', $value);
$this->validateString('Title', $value);
if ($this->data['title'] === $value) {
return;
}
$this->data['title'] = $value;
$this->setModified('title');
}
/**
* Set the value of Reference / reference.
*
* Must not be null.
* @param $value string
*/
public function setReference($value)
{
$this->validateNotNull('Reference', $value);
$this->validateString('Reference', $value);
if ($this->data['reference'] === $value) {
return;
}
$this->data['reference'] = $value;
$this->setModified('reference');
}
/**
* Set the value of Branch / branch.
*
* Must not be null.
* @param $value string
*/
public function setBranch($value)
{
$this->validateNotNull('Branch', $value);
$this->validateString('Branch', $value);
if ($this->data['branch'] === $value) {
return;
}
$this->data['branch'] = $value;
$this->setModified('branch');
}
/**
* Set the value of SshPrivateKey / ssh_private_key.
*
* @param $value string
*/
public function setSshPrivateKey($value)
{
$this->validateString('SshPrivateKey', $value);
if ($this->data['ssh_private_key'] === $value) {
return;
}
$this->data['ssh_private_key'] = $value;
$this->setModified('ssh_private_key');
}
/**
* Set the value of Type / type.
*
* Must not be null.
* @param $value string
*/
public function setType($value)
{
$this->validateNotNull('Type', $value);
$this->validateString('Type', $value);
if ($this->data['type'] === $value) {
return;
}
$this->data['type'] = $value;
$this->setModified('type');
}
/**
* Set the value of AccessInformation / access_information.
*
* @param $value string
*/
public function setAccessInformation($value)
{
$this->validateString('AccessInformation', $value);
if ($this->data['access_information'] === $value) {
return;
}
$this->data['access_information'] = $value;
$this->setModified('access_information');
}
/**
* Set the value of LastCommit / last_commit.
*
* @param $value string
*/
public function setLastCommit($value)
{
$this->validateString('LastCommit', $value);
if ($this->data['last_commit'] === $value) {
return;
}
$this->data['last_commit'] = $value;
$this->setModified('last_commit');
}
/**
* Set the value of BuildConfig / build_config.
*
* @param $value string
*/
public function setBuildConfig($value)
{
$this->validateString('BuildConfig', $value);
if ($this->data['build_config'] === $value) {
return;
}
$this->data['build_config'] = $value;
$this->setModified('build_config');
}
/**
* Set the value of SshPublicKey / ssh_public_key.
*
* @param $value string
*/
public function setSshPublicKey($value)
{
$this->validateString('SshPublicKey', $value);
if ($this->data['ssh_public_key'] === $value) {
return;
}
$this->data['ssh_public_key'] = $value;
$this->setModified('ssh_public_key');
}
/**
* Set the value of AllowPublicStatus / allow_public_status.
*
* Must not be null.
* @param $value int
*/
public function setAllowPublicStatus($value)
{
$this->validateNotNull('AllowPublicStatus', $value);
$this->validateInt('AllowPublicStatus', $value);
if ($this->data['allow_public_status'] === $value) {
return;
}
$this->data['allow_public_status'] = $value;
$this->setModified('allow_public_status');
}
/**
* Set the value of Archived / archived.
*
* Must not be null.
* @param $value int
*/
public function setArchived($value)
{
$this->validateNotNull('Archived', $value);
$this->validateInt('Archived', $value);
if ($this->data['archived'] === $value) {
return;
}
$this->data['archived'] = $value;
$this->setModified('archived');
}
/**
* Set the value of GroupId / group_id.
*
* Must not be null.
* @param $value int
*/
public function setGroupId($value)
{
$this->validateNotNull('GroupId', $value);
$this->validateInt('GroupId', $value);
if ($this->data['group_id'] === $value) {
return;
}
$this->data['group_id'] = $value;
$this->setModified('group_id');
}
/**
* Get the ProjectGroup model for this Project by Id.
*
* @uses \PHPCensor\Store\ProjectGroupStore::getById()
* @uses \PHPCensor\Model\ProjectGroup
* @return \PHPCensor\Model\ProjectGroup
*/
public function getGroup()
{
$key = $this->getGroupId();
if (empty($key)) {
return null;
}
$cacheKey = 'Cache.ProjectGroup.' . $key;
$rtn = $this->cache->get($cacheKey, null);
if (empty($rtn)) {
$rtn = Factory::getStore('ProjectGroup', 'PHPCensor')->getById($key);
$this->cache->set($cacheKey, $rtn);
}
return $rtn;
}
/**
* Set Group - Accepts an ID, an array representing a ProjectGroup or a ProjectGroup model.
*
* @param $value mixed
*/
public function setGroup($value)
{
// Is this an instance of ProjectGroup?
if ($value instanceof ProjectGroup) {
return $this->setGroupObject($value);
}
// Is this an array representing a ProjectGroup item?
if (is_array($value) && !empty($value['id'])) {
return $this->setGroupId($value['id']);
}
// Is this a scalar value representing the ID of this foreign key?
return $this->setGroupId($value);
}
/**
* Set Group - Accepts a ProjectGroup model.
*
* @param $value ProjectGroup
*/
public function setGroupObject(ProjectGroup $value)
{
return $this->setGroupId($value->getId());
}
/**
* Get Build models by ProjectId for this Project.
*
* @uses \PHPCensor\Store\BuildStore::getByProjectId()
* @uses \PHPCensor\Model\Build
* @return \PHPCensor\Model\Build[]
*/
public function getProjectBuilds()
{
return Factory::getStore('Build', 'PHPCensor')->getByProjectId($this->getId());
}
/**
* Get BuildMeta models by ProjectId for this Project.
*
* @uses \PHPCensor\Store\BuildMetaStore::getByProjectId()
* @uses \PHPCensor\Model\BuildMeta
* @return \PHPCensor\Model\BuildMeta[]
*/
public function getProjectBuildMetas()
{
return Factory::getStore('BuildMeta', 'PHPCensor')->getByProjectId($this->getId());
}
}

View file

@ -1,165 +0,0 @@
<?php
/**
* ProjectGroup base model for table: project_group
*/
namespace PHPCensor\Model\Base;
use PHPCensor\Model;
use b8\Store\Factory;
/**
* ProjectGroup Base Model
*/
class ProjectGroupBase extends Model
{
/**
* @var array
*/
public static $sleepable = [];
/**
* @var string
*/
protected $tableName = 'project_group';
/**
* @var string
*/
protected $modelName = 'ProjectGroup';
/**
* @var array
*/
protected $data = [
'id' => null,
'title' => null,
];
/**
* @var array
*/
protected $getters = [
// Direct property getters:
'id' => 'getId',
'title' => 'getTitle',
// Foreign key getters:
];
/**
* @var array
*/
protected $setters = [
// Direct property setters:
'id' => 'setId',
'title' => 'setTitle',
// Foreign key setters:
];
/**
* @var array
*/
public $columns = [
'id' => [
'type' => 'int',
'length' => 11,
'primary_key' => true,
'auto_increment' => true,
'default' => null,
],
'title' => [
'type' => 'varchar',
'length' => 100,
'default' => null,
],
];
/**
* @var array
*/
public $indexes = [
'PRIMARY' => ['unique' => true, 'columns' => 'id'],
];
/**
* @var array
*/
public $foreignKeys = [];
/**
* Get the value of Id / id.
*
* @return int
*/
public function getId()
{
$rtn = $this->data['id'];
return $rtn;
}
/**
* Get the value of Title / title.
*
* @return string
*/
public function getTitle()
{
$rtn = $this->data['title'];
return $rtn;
}
/**
* Set the value of Id / id.
*
* Must not be null.
* @param $value int
*/
public function setId($value)
{
$this->validateNotNull('Id', $value);
$this->validateInt('Id', $value);
if ($this->data['id'] === $value) {
return;
}
$this->data['id'] = $value;
$this->setModified('id');
}
/**
* Set the value of Title / title.
*
* Must not be null.
* @param $value string
*/
public function setTitle($value)
{
$this->validateNotNull('Title', $value);
$this->validateString('Title', $value);
if ($this->data['title'] === $value) {
return;
}
$this->data['title'] = $value;
$this->setModified('title');
}
/**
* Get Project models by GroupId for this ProjectGroup.
*
* @uses \PHPCensor\Store\ProjectStore::getByGroupId()
* @uses \PHPCensor\Model\Project
* @return \PHPCensor\Model\Project[]
*/
public function getGroupProjects()
{
return Factory::getStore('Project', 'PHPCensor')->getByGroupId($this->getId(), false);
}
}

View file

@ -1,441 +0,0 @@
<?php
/**
* User base model for table: user
*/
namespace PHPCensor\Model\Base;
use b8\Config;
use PHPCensor\Model;
/**
* User Base Model
*/
class UserBase extends Model
{
/**
* @var array
*/
public static $sleepable = [];
/**
* @var string
*/
protected $tableName = 'user';
/**
* @var string
*/
protected $modelName = 'User';
/**
* @var array
*/
protected $data = [
'id' => null,
'email' => null,
'hash' => null,
'is_admin' => null,
'name' => null,
'language' => null,
'per_page' => null,
'provider_key' => null,
'provider_data' => null,
];
/**
* @var array
*/
protected $getters = [
// Direct property getters:
'id' => 'getId',
'email' => 'getEmail',
'hash' => 'getHash',
'is_admin' => 'getIsAdmin',
'name' => 'getName',
'language' => 'getLanguage',
'per_page' => 'getPerPage',
'provider_key' => 'getProviderKey',
'provider_data' => 'getProviderData',
// Foreign key getters:
];
/**
* @var array
*/
protected $setters = [
// Direct property setters:
'id' => 'setId',
'email' => 'setEmail',
'hash' => 'setHash',
'is_admin' => 'setIsAdmin',
'name' => 'setName',
'language' => 'setLanguage',
'per_page' => 'setPerPage',
'provider_key' => 'setProviderKey',
'provider_data' => 'setProviderData',
// Foreign key setters:
];
/**
* @var array
*/
public $columns = [
'id' => [
'type' => 'int',
'length' => 11,
'primary_key' => true,
'auto_increment' => true,
'default' => null,
],
'email' => [
'type' => 'varchar',
'length' => 250,
'default' => null,
],
'hash' => [
'type' => 'varchar',
'length' => 250,
'default' => null,
],
'is_admin' => [
'type' => 'int',
'length' => 11,
],
'name' => [
'type' => 'varchar',
'length' => 250,
'default' => null,
],
'language' => [
'type' => 'varchar',
'length' => 5,
'default' => null,
],
'per_page' => [
'type' => 'int',
'length' => 11,
'default' => null,
],
'provider_key' => [
'type' => 'varchar',
'length' => 255,
'default' => 'internal',
],
'provider_data' => [
'type' => 'varchar',
'length' => 255,
'nullable' => true,
'default' => null,
],
];
/**
* @var array
*/
public $indexes = [
'PRIMARY' => ['unique' => true, 'columns' => 'id'],
'idx_email' => ['unique' => true, 'columns' => 'email'],
'email' => ['unique' => true, 'columns' => 'email'],
'name' => ['columns' => 'name'],
];
/**
* @var array
*/
public $foreignKeys = [];
/**
* Get the value of Id / id.
*
* @return int
*/
public function getId()
{
$rtn = $this->data['id'];
return $rtn;
}
/**
* Get the value of Email / email.
*
* @return string
*/
public function getEmail()
{
$rtn = $this->data['email'];
return $rtn;
}
/**
* Get the value of Hash / hash.
*
* @return string
*/
public function getHash()
{
$rtn = $this->data['hash'];
return $rtn;
}
/**
* Get the value of Name / name.
*
* @return string
*/
public function getName()
{
$rtn = $this->data['name'];
return $rtn;
}
/**
* Get the value of IsAdmin / is_admin.
*
* @return int
*/
public function getIsAdmin()
{
$rtn = $this->data['is_admin'];
return $rtn;
}
/**
* Get the value of ProviderKey / provider_key.
*
* @return string
*/
public function getProviderKey()
{
$rtn = $this->data['provider_key'];
return $rtn;
}
/**
* Get the value of ProviderData / provider_data.
*
* @return string
*/
public function getProviderData()
{
$rtn = $this->data['provider_data'];
return $rtn;
}
/**
* Get the value of Language / language.
*
* @return string
*/
public function getLanguage()
{
$rtn = $this->data['language'];
return $rtn;
}
/**
* Get the value of PerPage / per_page.
*
* @return string
*/
public function getPerPage()
{
$rtn = $this->data['per_page'];
return $rtn;
}
/**
* Set the value of Id / id.
*
* Must not be null.
* @param $value int
*/
public function setId($value)
{
$this->validateNotNull('Id', $value);
$this->validateInt('Id', $value);
if ($this->data['id'] === $value) {
return;
}
$this->data['id'] = $value;
$this->setModified('id');
}
/**
* Set the value of Email / email.
*
* Must not be null.
* @param $value string
*/
public function setEmail($value)
{
$this->validateNotNull('Email', $value);
$this->validateString('Email', $value);
if ($this->data['email'] === $value) {
return;
}
$this->data['email'] = $value;
$this->setModified('email');
}
/**
* Set the value of Hash / hash.
*
* Must not be null.
* @param $value string
*/
public function setHash($value)
{
$this->validateNotNull('Hash', $value);
$this->validateString('Hash', $value);
if ($this->data['hash'] === $value) {
return;
}
$this->data['hash'] = $value;
$this->setModified('hash');
}
/**
* Set the value of Name / name.
*
* Must not be null.
* @param $value string
*/
public function setName($value)
{
$this->validateNotNull('Name', $value);
$this->validateString('Name', $value);
if ($this->data['name'] === $value) {
return;
}
$this->data['name'] = $value;
$this->setModified('name');
}
/**
* Set the value of IsAdmin / is_admin.
*
* Must not be null.
* @param $value int
*/
public function setIsAdmin($value)
{
$this->validateNotNull('IsAdmin', $value);
$this->validateInt('IsAdmin', $value);
if ($this->data['is_admin'] === $value) {
return;
}
$this->data['is_admin'] = $value;
$this->setModified('is_admin');
}
/**
* Set the value of ProviderKey / provider_key.
*
* Must not be null.
* @param $value string
*/
public function setProviderKey($value)
{
$this->validateNotNull('ProviderKey', $value);
$this->validateString('ProviderKey', $value);
if ($this->data['provider_key'] === $value) {
return;
}
$this->data['provider_key'] = $value;
$this->setModified('provider_key');
}
/**
* Set the value of ProviderData / provider_data.
*
* @param $value string
*/
public function setProviderData($value)
{
$this->validateString('ProviderData', $value);
if ($this->data['provider_data'] === $value) {
return;
}
$this->data['provider_data'] = $value;
$this->setModified('provider_data');
}
/**
* Set the value of Language / language.
*
* Must not be null.
* @param $value string
*/
public function setLanguage($value)
{
if ($this->data['language'] === $value) {
return;
}
$this->data['language'] = $value;
$this->setModified('language');
}
/**
* Set the value of PerPage / per_page.
*
* Must not be null.
* @param $value string
*/
public function setPerPage($value)
{
if ($this->data['per_page'] === $value) {
return;
}
$this->data['per_page'] = $value;
$this->setModified('per_page');
}
/**
* @return integer
*/
public function getFinalPerPage()
{
$perPage = $this->getPerPage();
if ($perPage) {
return (integer)$perPage;
}
return (integer)Config::getInstance()->get('php-censor.per_page', 10);
}
}

View file

@ -1,26 +1,605 @@
<?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\Model;
use b8\Store\Factory;
use PHPCensor\Model\Base\BuildBase;
use PHPCensor\Builder;
use Symfony\Component\Yaml\Parser as YamlParser;
use PHPCensor\Model;
use b8\Store\Factory;
/**
* Build Model
*
* @author Dan Cryer <dan@block8.co.uk>
*/
class Build extends BuildBase
class Build extends Model
{
/**
* @var array
*/
public static $sleepable = [];
/**
* @var string
*/
protected $tableName = 'build';
/**
* @var string
*/
protected $modelName = 'Build';
/**
* @var array
*/
protected $data = [
'id' => null,
'project_id' => null,
'commit_id' => null,
'status' => null,
'log' => null,
'branch' => null,
'created' => null,
'started' => null,
'finished' => null,
'committer_email' => null,
'commit_message' => null,
'extra' => null,
];
/**
* @var array
*/
protected $getters = [
// Direct property getters:
'id' => 'getId',
'project_id' => 'getProjectId',
'commit_id' => 'getCommitId',
'status' => 'getStatus',
'log' => 'getLog',
'branch' => 'getBranch',
'created' => 'getCreated',
'started' => 'getStarted',
'finished' => 'getFinished',
'committer_email' => 'getCommitterEmail',
'commit_message' => 'getCommitMessage',
'extra' => 'getExtra',
// Foreign key getters:
'Project' => 'getProject',
];
/**
* @var array
*/
protected $setters = [
// Direct property setters:
'id' => 'setId',
'project_id' => 'setProjectId',
'commit_id' => 'setCommitId',
'status' => 'setStatus',
'log' => 'setLog',
'branch' => 'setBranch',
'created' => 'setCreated',
'started' => 'setStarted',
'finished' => 'setFinished',
'committer_email' => 'setCommitterEmail',
'commit_message' => 'setCommitMessage',
'extra' => 'setExtra',
// Foreign key setters:
'Project' => 'setProject',
];
/**
* @var array
*/
public $columns = [
'id' => [
'type' => 'int',
'length' => 11,
'primary_key' => true,
'auto_increment' => true,
'default' => null,
],
'project_id' => [
'type' => 'int',
'length' => 11,
'default' => null,
],
'commit_id' => [
'type' => 'varchar',
'length' => 50,
'default' => null,
],
'status' => [
'type' => 'int',
'length' => 11,
'default' => null,
],
'log' => [
'type' => 'mediumtext',
'nullable' => true,
'default' => null,
],
'branch' => [
'type' => 'varchar',
'length' => 250,
'default' => 'master',
],
'created' => [
'type' => 'datetime',
'nullable' => true,
'default' => null,
],
'started' => [
'type' => 'datetime',
'nullable' => true,
'default' => null,
],
'finished' => [
'type' => 'datetime',
'nullable' => true,
'default' => null,
],
'committer_email' => [
'type' => 'varchar',
'length' => 512,
'nullable' => true,
'default' => null,
],
'commit_message' => [
'type' => 'text',
'nullable' => true,
'default' => null,
],
'extra' => [
'type' => 'text',
'nullable' => true,
'default' => null,
],
];
/**
* @var array
*/
public $indexes = [
'PRIMARY' => ['unique' => true, 'columns' => 'id'],
'project_id' => ['columns' => 'project_id'],
'idx_status' => ['columns' => 'status'],
];
/**
* @var array
*/
public $foreignKeys = [
'build_ibfk_1' => [
'local_col' => 'project_id',
'update' => 'CASCADE',
'delete' => 'CASCADE',
'table' => 'project',
'col' => 'id'
],
];
/**
* Get the value of Id / id.
*
* @return int
*/
public function getId()
{
$rtn = $this->data['id'];
return $rtn;
}
/**
* Get the value of ProjectId / project_id.
*
* @return int
*/
public function getProjectId()
{
$rtn = $this->data['project_id'];
return $rtn;
}
/**
* Get the value of CommitId / commit_id.
*
* @return string
*/
public function getCommitId()
{
$rtn = $this->data['commit_id'];
return $rtn;
}
/**
* Get the value of Status / status.
*
* @return int
*/
public function getStatus()
{
$rtn = $this->data['status'];
return $rtn;
}
/**
* Get the value of Log / log.
*
* @return string
*/
public function getLog()
{
$rtn = $this->data['log'];
return $rtn;
}
/**
* Get the value of Branch / branch.
*
* @return string
*/
public function getBranch()
{
$rtn = $this->data['branch'];
return $rtn;
}
/**
* Get the value of Created / created.
*
* @return \DateTime
*/
public function getCreated()
{
$rtn = $this->data['created'];
if (!empty($rtn)) {
$rtn = new \DateTime($rtn);
}
return $rtn;
}
/**
* Get the value of Started / started.
*
* @return \DateTime
*/
public function getStarted()
{
$rtn = $this->data['started'];
if (!empty($rtn)) {
$rtn = new \DateTime($rtn);
}
return $rtn;
}
/**
* Get the value of Finished / finished.
*
* @return \DateTime
*/
public function getFinished()
{
$rtn = $this->data['finished'];
if (!empty($rtn)) {
$rtn = new \DateTime($rtn);
}
return $rtn;
}
/**
* Get the value of CommitterEmail / committer_email.
*
* @return string
*/
public function getCommitterEmail()
{
$rtn = $this->data['committer_email'];
return $rtn;
}
/**
* Set the value of Id / id. Must not be null.
*
* @param $value int
*/
public function setId($value)
{
$this->validateNotNull('Id', $value);
$this->validateInt('Id', $value);
if ($this->data['id'] === $value) {
return;
}
$this->data['id'] = $value;
$this->setModified('id');
}
/**
* Set the value of ProjectId / project_id. Must not be null.
*
* @param $value int
*/
public function setProjectId($value)
{
$this->validateNotNull('ProjectId', $value);
$this->validateInt('ProjectId', $value);
if ($this->data['project_id'] === $value) {
return;
}
$this->data['project_id'] = $value;
$this->setModified('project_id');
}
/**
* Set the value of CommitId / commit_id. Must not be null.
*
* @param $value string
*/
public function setCommitId($value)
{
$this->validateNotNull('CommitId', $value);
$this->validateString('CommitId', $value);
if ($this->data['commit_id'] === $value) {
return;
}
$this->data['commit_id'] = $value;
$this->setModified('commit_id');
}
/**
* Set the value of Status / status. Must not be null.
*
* @param $value int
*/
public function setStatus($value)
{
$this->validateNotNull('Status', $value);
$this->validateInt('Status', $value);
if ($this->data['status'] === $value) {
return;
}
$this->data['status'] = $value;
$this->setModified('status');
}
/**
* Set the value of Log / log.
*
* @param $value string
*/
public function setLog($value)
{
$this->validateString('Log', $value);
if ($this->data['log'] === $value) {
return;
}
$this->data['log'] = $value;
$this->setModified('log');
}
/**
* Set the value of Branch / branch. Must not be null.
*
* @param $value string
*/
public function setBranch($value)
{
$this->validateNotNull('Branch', $value);
$this->validateString('Branch', $value);
if ($this->data['branch'] === $value) {
return;
}
$this->data['branch'] = $value;
$this->setModified('branch');
}
/**
* Set the value of Created / created.
*
* @param $value \DateTime
*/
public function setCreated($value)
{
$this->validateDate('Created', $value);
if ($this->data['created'] === $value) {
return;
}
$this->data['created'] = $value;
$this->setModified('created');
}
/**
* Set the value of Started / started.
*
* @param $value \DateTime
*/
public function setStarted($value)
{
$this->validateDate('Started', $value);
if ($this->data['started'] === $value) {
return;
}
$this->data['started'] = $value;
$this->setModified('started');
}
/**
* Set the value of Finished / finished.
*
* @param $value \DateTime
*/
public function setFinished($value)
{
$this->validateDate('Finished', $value);
if ($this->data['finished'] === $value) {
return;
}
$this->data['finished'] = $value;
$this->setModified('finished');
}
/**
* Set the value of CommitterEmail / committer_email.
*
* @param $value string
*/
public function setCommitterEmail($value)
{
$this->validateString('CommitterEmail', $value);
if ($this->data['committer_email'] === $value) {
return;
}
$this->data['committer_email'] = $value;
$this->setModified('committer_email');
}
/**
* Set the value of CommitMessage / commit_message.
*
* @param $value string
*/
public function setCommitMessage($value)
{
$this->validateString('CommitMessage', $value);
if ($this->data['commit_message'] === $value) {
return;
}
$this->data['commit_message'] = $value;
$this->setModified('commit_message');
}
/**
* Set the value of Extra / extra.
*
* @param $value string
*/
public function setExtra($value)
{
$this->validateString('Extra', $value);
if ($this->data['extra'] === $value) {
return;
}
$this->data['extra'] = $value;
$this->setModified('extra');
}
/**
* Get the Project model for this Build by Id.
*
* @return \PHPCensor\Model\Project
*/
public function getProject()
{
$key = $this->getProjectId();
if (empty($key)) {
return null;
}
return Factory::getStore('Project', 'PHPCensor')->getById($key);
}
/**
* Set Project - Accepts an ID, an array representing a Project or a Project model.
*
* @param $value mixed
*/
public function setProject($value)
{
// Is this an instance of Project?
if ($value instanceof Project) {
return $this->setProjectObject($value);
}
// Is this an array representing a Project item?
if (is_array($value) && !empty($value['id'])) {
return $this->setProjectId($value['id']);
}
// Is this a scalar value representing the ID of this foreign key?
return $this->setProjectId($value);
}
/**
* Set Project - Accepts a Project model.
*
* @param $value Project
*/
public function setProjectObject(Project $value)
{
return $this->setProjectId($value->getId());
}
/**
* Get BuildError models by BuildId for this Build.
*
* @return \PHPCensor\Model\BuildError[]
*/
public function getBuildBuildErrors()
{
return Factory::getStore('BuildError', 'PHPCensor')->getByBuildId($this->getId());
}
/**
* Get BuildMeta models by BuildId for this Build.
*
* @return \PHPCensor\Model\BuildMeta[]
*/
public function getBuildBuildMetas()
{
return Factory::getStore('BuildMeta', 'PHPCensor')->getByBuildId($this->getId());
}
const STATUS_PENDING = 0;
const STATUS_RUNNING = 1;
const STATUS_SUCCESS = 2;

View file

@ -1,18 +1,499 @@
<?php
/**
* BuildError model for table: build_error
*/
namespace PHPCensor\Model;
use PHPCensor\Model\Base\BuildErrorBase;
use PHPCensor\Model;
use b8\Store\Factory;
/**
* BuildError Model
*/
class BuildError extends BuildErrorBase
class BuildError extends Model
{
/**
* @var array
*/
public static $sleepable = [];
/**
* @var string
*/
protected $tableName = 'build_error';
/**
* @var string
*/
protected $modelName = 'BuildError';
/**
* @var array
*/
protected $data = [
'id' => null,
'build_id' => null,
'plugin' => null,
'file' => null,
'line_start' => null,
'line_end' => null,
'severity' => null,
'message' => null,
'created_date' => null,
];
/**
* @var array
*/
protected $getters = [
// Direct property getters:
'id' => 'getId',
'build_id' => 'getBuildId',
'plugin' => 'getPlugin',
'file' => 'getFile',
'line_start' => 'getLineStart',
'line_end' => 'getLineEnd',
'severity' => 'getSeverity',
'message' => 'getMessage',
'created_date' => 'getCreatedDate',
// Foreign key getters:
'Build' => 'getBuild',
];
/**
* @var array
*/
protected $setters = [
// Direct property setters:
'id' => 'setId',
'build_id' => 'setBuildId',
'plugin' => 'setPlugin',
'file' => 'setFile',
'line_start' => 'setLineStart',
'line_end' => 'setLineEnd',
'severity' => 'setSeverity',
'message' => 'setMessage',
'created_date' => 'setCreatedDate',
// Foreign key setters:
'Build' => 'setBuild',
];
/**
* @var array
*/
public $columns = [
'id' => [
'type' => 'int',
'length' => 11,
'primary_key' => true,
'auto_increment' => true,
'default' => null,
],
'build_id' => [
'type' => 'int',
'length' => 11,
'default' => null,
],
'plugin' => [
'type' => 'varchar',
'length' => 100,
'default' => null,
],
'file' => [
'type' => 'varchar',
'length' => 250,
'nullable' => true,
'default' => null,
],
'line_start' => [
'type' => 'int',
'length' => 11,
'nullable' => true,
'default' => null,
],
'line_end' => [
'type' => 'int',
'length' => 11,
'nullable' => true,
'default' => null,
],
'severity' => [
'type' => 'tinyint',
'length' => 3,
'default' => null,
],
'message' => [
'type' => 'varchar',
'length' => 250,
'default' => null,
],
'created_date' => [
'type' => 'datetime',
'default' => null,
],
];
/**
* @var array
*/
public $indexes = [
'PRIMARY' => ['unique' => true, 'columns' => 'id'],
'build_id' => ['columns' => 'build_id, created_date'],
];
/**
* @var array
*/
public $foreignKeys = [
'build_error_ibfk_1' => [
'local_col' => 'build_id',
'update' => 'CASCADE',
'delete' => 'CASCADE',
'table' => 'build',
'col' => 'id'
],
];
/**
* Get the value of Id / id.
*
* @return int
*/
public function getId()
{
$rtn = $this->data['id'];
return $rtn;
}
/**
* Get the value of BuildId / build_id.
*
* @return int
*/
public function getBuildId()
{
$rtn = $this->data['build_id'];
return $rtn;
}
/**
* Get the value of Plugin / plugin.
*
* @return string
*/
public function getPlugin()
{
$rtn = $this->data['plugin'];
return $rtn;
}
/**
* Get the value of File / file.
*
* @return string
*/
public function getFile()
{
$rtn = $this->data['file'];
return $rtn;
}
/**
* Get the value of LineStart / line_start.
*
* @return int
*/
public function getLineStart()
{
$rtn = $this->data['line_start'];
return $rtn;
}
/**
* Get the value of LineEnd / line_end.
*
* @return int
*/
public function getLineEnd()
{
$rtn = $this->data['line_end'];
return $rtn;
}
/**
* Get the value of Severity / severity.
*
* @return int
*/
public function getSeverity()
{
$rtn = $this->data['severity'];
return $rtn;
}
/**
* Get the value of Message / message.
*
* @return string
*/
public function getMessage()
{
$rtn = $this->data['message'];
return $rtn;
}
/**
* Get the value of CreatedDate / created_date.
*
* @return \DateTime
*/
public function getCreatedDate()
{
$rtn = $this->data['created_date'];
if (!empty($rtn)) {
$rtn = new \DateTime($rtn);
}
return $rtn;
}
/**
* Set the value of Id / id.
*
* Must not be null.
* @param $value int
*/
public function setId($value)
{
$this->validateNotNull('Id', $value);
$this->validateInt('Id', $value);
if ($this->data['id'] === $value) {
return;
}
$this->data['id'] = $value;
$this->setModified('id');
}
/**
* Set the value of BuildId / build_id.
*
* Must not be null.
* @param $value int
*/
public function setBuildId($value)
{
$this->validateNotNull('BuildId', $value);
$this->validateInt('BuildId', $value);
if ($this->data['build_id'] === $value) {
return;
}
$this->data['build_id'] = $value;
$this->setModified('build_id');
}
/**
* Set the value of Plugin / plugin.
*
* Must not be null.
* @param $value string
*/
public function setPlugin($value)
{
$this->validateNotNull('Plugin', $value);
$this->validateString('Plugin', $value);
if ($this->data['plugin'] === $value) {
return;
}
$this->data['plugin'] = $value;
$this->setModified('plugin');
}
/**
* Set the value of File / file.
*
* @param $value string
*/
public function setFile($value)
{
$this->validateString('File', $value);
if ($this->data['file'] === $value) {
return;
}
$this->data['file'] = $value;
$this->setModified('file');
}
/**
* Set the value of LineStart / line_start.
*
* @param $value int
*/
public function setLineStart($value)
{
$this->validateInt('LineStart', $value);
if ($this->data['line_start'] === $value) {
return;
}
$this->data['line_start'] = $value;
$this->setModified('line_start');
}
/**
* Set the value of LineEnd / line_end.
*
* @param $value int
*/
public function setLineEnd($value)
{
$this->validateInt('LineEnd', $value);
if ($this->data['line_end'] === $value) {
return;
}
$this->data['line_end'] = $value;
$this->setModified('line_end');
}
/**
* Set the value of Severity / severity.
*
* Must not be null.
* @param $value int
*/
public function setSeverity($value)
{
$this->validateNotNull('Severity', $value);
$this->validateInt('Severity', $value);
if ($this->data['severity'] === $value) {
return;
}
$this->data['severity'] = $value;
$this->setModified('severity');
}
/**
* Set the value of Message / message.
*
* Must not be null.
* @param $value string
*/
public function setMessage($value)
{
$this->validateNotNull('Message', $value);
$this->validateString('Message', $value);
if ($this->data['message'] === $value) {
return;
}
$this->data['message'] = $value;
$this->setModified('message');
}
/**
* Set the value of CreatedDate / created_date.
*
* Must not be null.
* @param $value \DateTime
*/
public function setCreatedDate($value)
{
$this->validateNotNull('CreatedDate', $value);
$this->validateDate('CreatedDate', $value);
if ($this->data['created_date'] === $value) {
return;
}
$this->data['created_date'] = $value;
$this->setModified('created_date');
}
/**
* Get the Build model for this BuildError by Id.
*
* @uses \PHPCensor\Store\BuildStore::getById()
* @uses \PHPCensor\Model\Build
* @return \PHPCensor\Model\Build
*/
public function getBuild()
{
$key = $this->getBuildId();
if (empty($key)) {
return null;
}
$cacheKey = 'Cache.Build.' . $key;
$rtn = $this->cache->get($cacheKey, null);
if (empty($rtn)) {
$rtn = Factory::getStore('Build', 'PHPCensor')->getById($key);
$this->cache->set($cacheKey, $rtn);
}
return $rtn;
}
/**
* Set Build - Accepts an ID, an array representing a Build or a Build model.
*
* @param $value mixed
*/
public function setBuild($value)
{
// Is this an instance of Build?
if ($value instanceof Build) {
return $this->setBuildObject($value);
}
// Is this an array representing a Build item?
if (is_array($value) && !empty($value['id'])) {
return $this->setBuildId($value['id']);
}
// Is this a scalar value representing the ID of this foreign key?
return $this->setBuildId($value);
}
/**
* Set Build - Accepts a Build model.
*
* @param $value Build
*/
public function setBuildObject(Build $value)
{
return $this->setBuildId($value->getId());
}
const SEVERITY_CRITICAL = 0;
const SEVERITY_HIGH = 1;
const SEVERITY_NORMAL = 2;

View file

@ -1,22 +1,400 @@
<?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\Model;
use PHPCensor\Model\Base\BuildMetaBase;
use PHPCensor\Model;
use b8\Store\Factory;
/**
* BuildMeta Model
*
* @uses PHPCensor\Model\Base\BuildMetaBase
*/
class BuildMeta extends BuildMetaBase
class BuildMeta extends Model
{
// This class has been left blank so that you can modify it - changes in this file will not be overwritten.
/**
* @var array
*/
public static $sleepable = [];
/**
* @var string
*/
protected $tableName = 'build_meta';
/**
* @var string
*/
protected $modelName = 'BuildMeta';
/**
* @var array
*/
protected $data = [
'id' => null,
'project_id' => null,
'build_id' => null,
'meta_key' => null,
'meta_value' => null,
];
/**
* @var array
*/
protected $getters = [
// Direct property getters:
'id' => 'getId',
'project_id' => 'getProjectId',
'build_id' => 'getBuildId',
'meta_key' => 'getMetaKey',
'meta_value' => 'getMetaValue',
// Foreign key getters:
'Project' => 'getProject',
'Build' => 'getBuild',
];
/**
* @var array
*/
protected $setters = [
// Direct property setters:
'id' => 'setId',
'project_id' => 'setProjectId',
'build_id' => 'setBuildId',
'meta_key' => 'setMetaKey',
'meta_value' => 'setMetaValue',
// Foreign key setters:
'Project' => 'setProject',
'Build' => 'setBuild',
];
/**
* @var array
*/
public $columns = [
'id' => [
'type' => 'int',
'length' => 10,
'primary_key' => true,
'auto_increment' => true,
'default' => null,
],
'project_id' => [
'type' => 'int',
'length' => 11,
'default' => null,
],
'build_id' => [
'type' => 'int',
'length' => 11,
'default' => null,
],
'meta_key' => [
'type' => 'varchar',
'length' => 250,
'default' => null,
],
'meta_value' => [
'type' => 'mediumtext',
'default' => null,
],
];
/**
* @var array
*/
public $indexes = [
'PRIMARY' => ['unique' => true, 'columns' => 'id'],
'idx_meta_id' => ['unique' => true, 'columns' => 'build_id, meta_key'],
'project_id' => ['columns' => 'project_id'],
];
/**
* @var array
*/
public $foreignKeys = [
'build_meta_ibfk_1' => [
'local_col' => 'project_id',
'update' => 'CASCADE',
'delete' => 'CASCADE',
'table' => 'project',
'col' => 'id'
],
'fk_meta_build_id' => [
'local_col' => 'build_id',
'update' => 'CASCADE',
'delete' => 'CASCADE',
'table' => 'build',
'col' => 'id'
],
];
/**
* Get the value of Id / id.
*
* @return int
*/
public function getId()
{
$rtn = $this->data['id'];
return $rtn;
}
/**
* Get the value of ProjectId / project_id.
*
* @return int
*/
public function getProjectId()
{
$rtn = $this->data['project_id'];
return $rtn;
}
/**
* Get the value of BuildId / build_id.
*
* @return int
*/
public function getBuildId()
{
$rtn = $this->data['build_id'];
return $rtn;
}
/**
* Get the value of MetaKey / meta_key.
*
* @return string
*/
public function getMetaKey()
{
$rtn = $this->data['meta_key'];
return $rtn;
}
/**
* Get the value of MetaValue / meta_value.
*
* @return string
*/
public function getMetaValue()
{
$rtn = $this->data['meta_value'];
return $rtn;
}
/**
* Set the value of Id / id.
*
* Must not be null.
* @param $value int
*/
public function setId($value)
{
$this->validateNotNull('Id', $value);
$this->validateInt('Id', $value);
if ($this->data['id'] === $value) {
return;
}
$this->data['id'] = $value;
$this->setModified('id');
}
/**
* Set the value of ProjectId / project_id.
*
* Must not be null.
* @param $value int
*/
public function setProjectId($value)
{
$this->validateNotNull('ProjectId', $value);
$this->validateInt('ProjectId', $value);
if ($this->data['project_id'] === $value) {
return;
}
$this->data['project_id'] = $value;
$this->setModified('project_id');
}
/**
* Set the value of BuildId / build_id.
*
* Must not be null.
* @param $value int
*/
public function setBuildId($value)
{
$this->validateNotNull('BuildId', $value);
$this->validateInt('BuildId', $value);
if ($this->data['build_id'] === $value) {
return;
}
$this->data['build_id'] = $value;
$this->setModified('build_id');
}
/**
* Set the value of MetaKey / meta_key.
*
* Must not be null.
* @param $value string
*/
public function setMetaKey($value)
{
$this->validateNotNull('MetaKey', $value);
$this->validateString('MetaKey', $value);
if ($this->data['meta_key'] === $value) {
return;
}
$this->data['meta_key'] = $value;
$this->setModified('meta_key');
}
/**
* Set the value of MetaValue / meta_value.
*
* Must not be null.
* @param $value string
*/
public function setMetaValue($value)
{
$this->validateNotNull('MetaValue', $value);
$this->validateString('MetaValue', $value);
if ($this->data['meta_value'] === $value) {
return;
}
$this->data['meta_value'] = $value;
$this->setModified('meta_value');
}
/**
* Get the Project model for this BuildMeta by Id.
*
* @uses \PHPCensor\Store\ProjectStore::getById()
* @uses \PHPCensor\Model\Project
* @return \PHPCensor\Model\Project
*/
public function getProject()
{
$key = $this->getProjectId();
if (empty($key)) {
return null;
}
$cacheKey = 'Cache.Project.' . $key;
$rtn = $this->cache->get($cacheKey, null);
if (empty($rtn)) {
$rtn = Factory::getStore('Project', 'PHPCensor')->getById($key);
$this->cache->set($cacheKey, $rtn);
}
return $rtn;
}
/**
* Set Project - Accepts an ID, an array representing a Project or a Project model.
*
* @param $value mixed
*/
public function setProject($value)
{
// Is this an instance of Project?
if ($value instanceof Project) {
return $this->setProjectObject($value);
}
// Is this an array representing a Project item?
if (is_array($value) && !empty($value['id'])) {
return $this->setProjectId($value['id']);
}
// Is this a scalar value representing the ID of this foreign key?
return $this->setProjectId($value);
}
/**
* Set Project - Accepts a Project model.
*
* @param $value Project
*/
public function setProjectObject(Project $value)
{
return $this->setProjectId($value->getId());
}
/**
* Get the Build model for this BuildMeta by Id.
*
* @uses \PHPCensor\Store\BuildStore::getById()
* @uses \PHPCensor\Model\Build
* @return \PHPCensor\Model\Build
*/
public function getBuild()
{
$key = $this->getBuildId();
if (empty($key)) {
return null;
}
$cacheKey = 'Cache.Build.' . $key;
$rtn = $this->cache->get($cacheKey, null);
if (empty($rtn)) {
$rtn = Factory::getStore('Build', 'PHPCensor')->getById($key);
$this->cache->set($cacheKey, $rtn);
}
return $rtn;
}
/**
* Set Build - Accepts an ID, an array representing a Build or a Build model.
*
* @param $value mixed
*/
public function setBuild($value)
{
// Is this an instance of Build?
if ($value instanceof Build) {
return $this->setBuildObject($value);
}
// Is this an array representing a Build item?
if (is_array($value) && !empty($value['id'])) {
return $this->setBuildId($value['id']);
}
// Is this a scalar value representing the ID of this foreign key?
return $this->setBuildId($value);
}
/**
* Set Build - Accepts a Build model.
*
* @param $value Build
*/
public function setBuildObject(Build $value)
{
return $this->setBuildId($value->getId());
}
}

View file

@ -1,27 +1,635 @@
<?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\Model;
use PHPCensor\Model\Base\ProjectBase;
use PHPCensor\Model\Build;
use PHPCensor\Model;
use b8\Store;
use b8\Store\Factory;
/**
* Project Model
* @uses PHPCensor\Model\Base\ProjectBase
* @author Dan Cryer <dan@block8.co.uk>
* @package PHPCI
* @subpackage Core
*/
class Project extends ProjectBase
* @author Dan Cryer <dan@block8.co.uk>
*/
class Project extends Model
{
/**
* @var array
*/
public static $sleepable = [];
/**
* @var string
*/
protected $tableName = 'project';
/**
* @var string
*/
protected $modelName = 'Project';
/**
* @var array
*/
protected $data = [
'id' => null,
'title' => null,
'reference' => null,
'branch' => null,
'ssh_private_key' => null,
'type' => null,
'access_information' => null,
'last_commit' => null,
'build_config' => null,
'ssh_public_key' => null,
'allow_public_status' => null,
'archived' => null,
'group_id' => null,
];
/**
* @var array
*/
protected $getters = [
// Direct property getters:
'id' => 'getId',
'title' => 'getTitle',
'reference' => 'getReference',
'branch' => 'getBranch',
'ssh_private_key' => 'getSshPrivateKey',
'type' => 'getType',
'access_information' => 'getAccessInformation',
'last_commit' => 'getLastCommit',
'build_config' => 'getBuildConfig',
'ssh_public_key' => 'getSshPublicKey',
'allow_public_status' => 'getAllowPublicStatus',
'archived' => 'getArchived',
'group_id' => 'getGroupId',
// Foreign key getters:
'Group' => 'getGroup',
];
/**
* @var array
*/
protected $setters = [
// Direct property setters:
'id' => 'setId',
'title' => 'setTitle',
'reference' => 'setReference',
'branch' => 'setBranch',
'ssh_private_key' => 'setSshPrivateKey',
'type' => 'setType',
'access_information' => 'setAccessInformation',
'last_commit' => 'setLastCommit',
'build_config' => 'setBuildConfig',
'ssh_public_key' => 'setSshPublicKey',
'allow_public_status' => 'setAllowPublicStatus',
'archived' => 'setArchived',
'group_id' => 'setGroupId',
// Foreign key setters:
'Group' => 'setGroup',
];
/**
* @var array
*/
public $columns = [
'id' => [
'type' => 'int',
'length' => 11,
'primary_key' => true,
'auto_increment' => true,
'default' => null,
],
'title' => [
'type' => 'varchar',
'length' => 250,
'default' => null,
],
'reference' => [
'type' => 'varchar',
'length' => 250,
'default' => null,
],
'branch' => [
'type' => 'varchar',
'length' => 250,
'default' => 'master',
],
'ssh_private_key' => [
'type' => 'text',
'nullable' => true,
'default' => null,
],
'type' => [
'type' => 'varchar',
'length' => 50,
'default' => null,
],
'access_information' => [
'type' => 'varchar',
'length' => 250,
'nullable' => true,
'default' => null,
],
'last_commit' => [
'type' => 'varchar',
'length' => 250,
'nullable' => true,
'default' => null,
],
'build_config' => [
'type' => 'text',
'nullable' => true,
'default' => null,
],
'ssh_public_key' => [
'type' => 'text',
'nullable' => true,
'default' => null,
],
'allow_public_status' => [
'type' => 'int',
'length' => 11,
],
'archived' => [
'type' => 'tinyint',
'length' => 1,
'default' => null,
],
'group_id' => [
'type' => 'int',
'length' => 11,
'default' => 1,
],
];
/**
* @var array
*/
public $indexes = [
'PRIMARY' => ['unique' => true, 'columns' => 'id'],
'idx_project_title' => ['columns' => 'title'],
'group_id' => ['columns' => 'group_id'],
];
/**
* @var array
*/
public $foreignKeys = [
'project_ibfk_1' => [
'local_col' => 'group_id',
'update' => 'CASCADE',
'delete' => '',
'table' => 'project_group',
'col' => 'id'
],
];
/**
* Get the value of Id / id.
*
* @return int
*/
public function getId()
{
$rtn = $this->data['id'];
return $rtn;
}
/**
* Get the value of Title / title.
*
* @return string
*/
public function getTitle()
{
$rtn = $this->data['title'];
return $rtn;
}
/**
* Get the value of Reference / reference.
*
* @return string
*/
public function getReference()
{
$rtn = $this->data['reference'];
return $rtn;
}
/**
* Get the value of SshPrivateKey / ssh_private_key.
*
* @return string
*/
public function getSshPrivateKey()
{
$rtn = $this->data['ssh_private_key'];
return $rtn;
}
/**
* Get the value of Type / type.
*
* @return string
*/
public function getType()
{
$rtn = $this->data['type'];
return $rtn;
}
/**
* Get the value of LastCommit / last_commit.
*
* @return string
*/
public function getLastCommit()
{
$rtn = $this->data['last_commit'];
return $rtn;
}
/**
* Get the value of BuildConfig / build_config.
*
* @return string
*/
public function getBuildConfig()
{
$rtn = $this->data['build_config'];
return $rtn;
}
/**
* Get the value of SshPublicKey / ssh_public_key.
*
* @return string
*/
public function getSshPublicKey()
{
$rtn = $this->data['ssh_public_key'];
return $rtn;
}
/**
* Get the value of AllowPublicStatus / allow_public_status.
*
* @return int
*/
public function getAllowPublicStatus()
{
$rtn = $this->data['allow_public_status'];
return $rtn;
}
/**
* Get the value of Archived / archived.
*
* @return int
*/
public function getArchived()
{
$rtn = $this->data['archived'];
return $rtn;
}
/**
* Get the value of GroupId / group_id.
*
* @return int
*/
public function getGroupId()
{
$rtn = $this->data['group_id'];
return $rtn;
}
/**
* Set the value of Id / id.
*
* Must not be null.
* @param $value int
*/
public function setId($value)
{
$this->validateNotNull('Id', $value);
$this->validateInt('Id', $value);
if ($this->data['id'] === $value) {
return;
}
$this->data['id'] = $value;
$this->setModified('id');
}
/**
* Set the value of Title / title.
*
* Must not be null.
* @param $value string
*/
public function setTitle($value)
{
$this->validateNotNull('Title', $value);
$this->validateString('Title', $value);
if ($this->data['title'] === $value) {
return;
}
$this->data['title'] = $value;
$this->setModified('title');
}
/**
* Set the value of Reference / reference.
*
* Must not be null.
* @param $value string
*/
public function setReference($value)
{
$this->validateNotNull('Reference', $value);
$this->validateString('Reference', $value);
if ($this->data['reference'] === $value) {
return;
}
$this->data['reference'] = $value;
$this->setModified('reference');
}
/**
* Set the value of Branch / branch.
*
* Must not be null.
* @param $value string
*/
public function setBranch($value)
{
$this->validateNotNull('Branch', $value);
$this->validateString('Branch', $value);
if ($this->data['branch'] === $value) {
return;
}
$this->data['branch'] = $value;
$this->setModified('branch');
}
/**
* Set the value of SshPrivateKey / ssh_private_key.
*
* @param $value string
*/
public function setSshPrivateKey($value)
{
$this->validateString('SshPrivateKey', $value);
if ($this->data['ssh_private_key'] === $value) {
return;
}
$this->data['ssh_private_key'] = $value;
$this->setModified('ssh_private_key');
}
/**
* Set the value of Type / type.
*
* Must not be null.
* @param $value string
*/
public function setType($value)
{
$this->validateNotNull('Type', $value);
$this->validateString('Type', $value);
if ($this->data['type'] === $value) {
return;
}
$this->data['type'] = $value;
$this->setModified('type');
}
/**
* Set the value of LastCommit / last_commit.
*
* @param $value string
*/
public function setLastCommit($value)
{
$this->validateString('LastCommit', $value);
if ($this->data['last_commit'] === $value) {
return;
}
$this->data['last_commit'] = $value;
$this->setModified('last_commit');
}
/**
* Set the value of BuildConfig / build_config.
*
* @param $value string
*/
public function setBuildConfig($value)
{
$this->validateString('BuildConfig', $value);
if ($this->data['build_config'] === $value) {
return;
}
$this->data['build_config'] = $value;
$this->setModified('build_config');
}
/**
* Set the value of SshPublicKey / ssh_public_key.
*
* @param $value string
*/
public function setSshPublicKey($value)
{
$this->validateString('SshPublicKey', $value);
if ($this->data['ssh_public_key'] === $value) {
return;
}
$this->data['ssh_public_key'] = $value;
$this->setModified('ssh_public_key');
}
/**
* Set the value of AllowPublicStatus / allow_public_status.
*
* Must not be null.
* @param $value int
*/
public function setAllowPublicStatus($value)
{
$this->validateNotNull('AllowPublicStatus', $value);
$this->validateInt('AllowPublicStatus', $value);
if ($this->data['allow_public_status'] === $value) {
return;
}
$this->data['allow_public_status'] = $value;
$this->setModified('allow_public_status');
}
/**
* Set the value of Archived / archived.
*
* Must not be null.
* @param $value int
*/
public function setArchived($value)
{
$this->validateNotNull('Archived', $value);
$this->validateInt('Archived', $value);
if ($this->data['archived'] === $value) {
return;
}
$this->data['archived'] = $value;
$this->setModified('archived');
}
/**
* Set the value of GroupId / group_id.
*
* Must not be null.
* @param $value int
*/
public function setGroupId($value)
{
$this->validateNotNull('GroupId', $value);
$this->validateInt('GroupId', $value);
if ($this->data['group_id'] === $value) {
return;
}
$this->data['group_id'] = $value;
$this->setModified('group_id');
}
/**
* Get the ProjectGroup model for this Project by Id.
*
* @uses \PHPCensor\Store\ProjectGroupStore::getById()
* @uses \PHPCensor\Model\ProjectGroup
* @return \PHPCensor\Model\ProjectGroup
*/
public function getGroup()
{
$key = $this->getGroupId();
if (empty($key)) {
return null;
}
$cacheKey = 'Cache.ProjectGroup.' . $key;
$rtn = $this->cache->get($cacheKey, null);
if (empty($rtn)) {
$rtn = Factory::getStore('ProjectGroup', 'PHPCensor')->getById($key);
$this->cache->set($cacheKey, $rtn);
}
return $rtn;
}
/**
* Set Group - Accepts an ID, an array representing a ProjectGroup or a ProjectGroup model.
*
* @param $value mixed
*/
public function setGroup($value)
{
// Is this an instance of ProjectGroup?
if ($value instanceof ProjectGroup) {
return $this->setGroupObject($value);
}
// Is this an array representing a ProjectGroup item?
if (is_array($value) && !empty($value['id'])) {
return $this->setGroupId($value['id']);
}
// Is this a scalar value representing the ID of this foreign key?
return $this->setGroupId($value);
}
/**
* Set Group - Accepts a ProjectGroup model.
*
* @param $value ProjectGroup
*/
public function setGroupObject(ProjectGroup $value)
{
return $this->setGroupId($value->getId());
}
/**
* Get Build models by ProjectId for this Project.
*
* @uses \PHPCensor\Store\BuildStore::getByProjectId()
* @uses \PHPCensor\Model\Build
* @return \PHPCensor\Model\Build[]
*/
public function getProjectBuilds()
{
return Factory::getStore('Build', 'PHPCensor')->getByProjectId($this->getId());
}
/**
* Get BuildMeta models by ProjectId for this Project.
*
* @uses \PHPCensor\Store\BuildMetaStore::getByProjectId()
* @uses \PHPCensor\Model\BuildMeta
* @return \PHPCensor\Model\BuildMeta[]
*/
public function getProjectBuildMetas()
{
return Factory::getStore('BuildMeta', 'PHPCensor')->getByProjectId($this->getId());
}
/**
* Return the latest build from a specific branch, of a specific status, for this project.
* @param string $branch
@ -82,7 +690,15 @@ class Project extends ProjectBase
$value = json_encode($value);
}
parent::setAccessInformation($value);
$this->validateString('AccessInformation', $value);
if ($this->data['access_information'] === $value) {
return;
}
$this->data['access_information'] = $value;
$this->setModified('access_information');
}
/**

View file

@ -1,18 +1,158 @@
<?php
/**
* ProjectGroup model for table: project_group
*/
namespace PHPCensor\Model;
use PHPCensor\Model\Base\ProjectGroupBase;
use PHPCensor\Model;
use b8\Store\Factory;
/**
* ProjectGroup Model
* @uses PHPCensor\Model\Base\ProjectGroupBase
*/
class ProjectGroup extends ProjectGroupBase
class ProjectGroup extends Model
{
// This class has been left blank so that you can modify it - changes in this file will not be overwritten.
/**
* @var array
*/
public static $sleepable = [];
/**
* @var string
*/
protected $tableName = 'project_group';
/**
* @var string
*/
protected $modelName = 'ProjectGroup';
/**
* @var array
*/
protected $data = [
'id' => null,
'title' => null,
];
/**
* @var array
*/
protected $getters = [
// Direct property getters:
'id' => 'getId',
'title' => 'getTitle',
// Foreign key getters:
];
/**
* @var array
*/
protected $setters = [
// Direct property setters:
'id' => 'setId',
'title' => 'setTitle',
// Foreign key setters:
];
/**
* @var array
*/
public $columns = [
'id' => [
'type' => 'int',
'length' => 11,
'primary_key' => true,
'auto_increment' => true,
'default' => null,
],
'title' => [
'type' => 'varchar',
'length' => 100,
'default' => null,
],
];
/**
* @var array
*/
public $indexes = [
'PRIMARY' => ['unique' => true, 'columns' => 'id'],
];
/**
* @var array
*/
public $foreignKeys = [];
/**
* Get the value of Id / id.
*
* @return int
*/
public function getId()
{
$rtn = $this->data['id'];
return $rtn;
}
/**
* Get the value of Title / title.
*
* @return string
*/
public function getTitle()
{
$rtn = $this->data['title'];
return $rtn;
}
/**
* Set the value of Id / id.
*
* Must not be null.
* @param $value int
*/
public function setId($value)
{
$this->validateNotNull('Id', $value);
$this->validateInt('Id', $value);
if ($this->data['id'] === $value) {
return;
}
$this->data['id'] = $value;
$this->setModified('id');
}
/**
* Set the value of Title / title.
*
* Must not be null.
* @param $value string
*/
public function setTitle($value)
{
$this->validateNotNull('Title', $value);
$this->validateString('Title', $value);
if ($this->data['title'] === $value) {
return;
}
$this->data['title'] = $value;
$this->setModified('title');
}
/**
* Get Project models by GroupId for this ProjectGroup.
*
* @uses \PHPCensor\Store\ProjectStore::getByGroupId()
* @uses \PHPCensor\Model\Project
* @return \PHPCensor\Model\Project[]
*/
public function getGroupProjects()
{
return Factory::getStore('Project', 'PHPCensor')->getByGroupId($this->getId(), false);
}
}

View file

@ -1,25 +1,437 @@
<?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\Model;
use PHPCensor\Model\Base\UserBase;
use b8\Config;
use PHPCensor\Model;
/**
* User Model
* @uses PHPCensor\Model\Base\UserBase
* @author Dan Cryer <dan@block8.co.uk>
* @package PHPCI
* @subpackage Core
*/
class User extends UserBase
* @author Dan Cryer <dan@block8.co.uk>
*/
class User extends Model
{
// This class has been left blank so that you can modify it - changes in this file will not be overwritten.
/**
* @var array
*/
public static $sleepable = [];
/**
* @var string
*/
protected $tableName = 'user';
/**
* @var string
*/
protected $modelName = 'User';
/**
* @var array
*/
protected $data = [
'id' => null,
'email' => null,
'hash' => null,
'is_admin' => null,
'name' => null,
'language' => null,
'per_page' => null,
'provider_key' => null,
'provider_data' => null,
];
/**
* @var array
*/
protected $getters = [
// Direct property getters:
'id' => 'getId',
'email' => 'getEmail',
'hash' => 'getHash',
'is_admin' => 'getIsAdmin',
'name' => 'getName',
'language' => 'getLanguage',
'per_page' => 'getPerPage',
'provider_key' => 'getProviderKey',
'provider_data' => 'getProviderData',
// Foreign key getters:
];
/**
* @var array
*/
protected $setters = [
// Direct property setters:
'id' => 'setId',
'email' => 'setEmail',
'hash' => 'setHash',
'is_admin' => 'setIsAdmin',
'name' => 'setName',
'language' => 'setLanguage',
'per_page' => 'setPerPage',
'provider_key' => 'setProviderKey',
'provider_data' => 'setProviderData',
// Foreign key setters:
];
/**
* @var array
*/
public $columns = [
'id' => [
'type' => 'int',
'length' => 11,
'primary_key' => true,
'auto_increment' => true,
'default' => null,
],
'email' => [
'type' => 'varchar',
'length' => 250,
'default' => null,
],
'hash' => [
'type' => 'varchar',
'length' => 250,
'default' => null,
],
'is_admin' => [
'type' => 'int',
'length' => 11,
],
'name' => [
'type' => 'varchar',
'length' => 250,
'default' => null,
],
'language' => [
'type' => 'varchar',
'length' => 5,
'default' => null,
],
'per_page' => [
'type' => 'int',
'length' => 11,
'default' => null,
],
'provider_key' => [
'type' => 'varchar',
'length' => 255,
'default' => 'internal',
],
'provider_data' => [
'type' => 'varchar',
'length' => 255,
'nullable' => true,
'default' => null,
],
];
/**
* @var array
*/
public $indexes = [
'PRIMARY' => ['unique' => true, 'columns' => 'id'],
'idx_email' => ['unique' => true, 'columns' => 'email'],
'email' => ['unique' => true, 'columns' => 'email'],
'name' => ['columns' => 'name'],
];
/**
* @var array
*/
public $foreignKeys = [];
/**
* Get the value of Id / id.
*
* @return int
*/
public function getId()
{
$rtn = $this->data['id'];
return $rtn;
}
/**
* Get the value of Email / email.
*
* @return string
*/
public function getEmail()
{
$rtn = $this->data['email'];
return $rtn;
}
/**
* Get the value of Hash / hash.
*
* @return string
*/
public function getHash()
{
$rtn = $this->data['hash'];
return $rtn;
}
/**
* Get the value of Name / name.
*
* @return string
*/
public function getName()
{
$rtn = $this->data['name'];
return $rtn;
}
/**
* Get the value of IsAdmin / is_admin.
*
* @return int
*/
public function getIsAdmin()
{
$rtn = $this->data['is_admin'];
return $rtn;
}
/**
* Get the value of ProviderKey / provider_key.
*
* @return string
*/
public function getProviderKey()
{
$rtn = $this->data['provider_key'];
return $rtn;
}
/**
* Get the value of ProviderData / provider_data.
*
* @return string
*/
public function getProviderData()
{
$rtn = $this->data['provider_data'];
return $rtn;
}
/**
* Get the value of Language / language.
*
* @return string
*/
public function getLanguage()
{
$rtn = $this->data['language'];
return $rtn;
}
/**
* Get the value of PerPage / per_page.
*
* @return string
*/
public function getPerPage()
{
$rtn = $this->data['per_page'];
return $rtn;
}
/**
* Set the value of Id / id.
*
* Must not be null.
* @param $value int
*/
public function setId($value)
{
$this->validateNotNull('Id', $value);
$this->validateInt('Id', $value);
if ($this->data['id'] === $value) {
return;
}
$this->data['id'] = $value;
$this->setModified('id');
}
/**
* Set the value of Email / email.
*
* Must not be null.
* @param $value string
*/
public function setEmail($value)
{
$this->validateNotNull('Email', $value);
$this->validateString('Email', $value);
if ($this->data['email'] === $value) {
return;
}
$this->data['email'] = $value;
$this->setModified('email');
}
/**
* Set the value of Hash / hash.
*
* Must not be null.
* @param $value string
*/
public function setHash($value)
{
$this->validateNotNull('Hash', $value);
$this->validateString('Hash', $value);
if ($this->data['hash'] === $value) {
return;
}
$this->data['hash'] = $value;
$this->setModified('hash');
}
/**
* Set the value of Name / name.
*
* Must not be null.
* @param $value string
*/
public function setName($value)
{
$this->validateNotNull('Name', $value);
$this->validateString('Name', $value);
if ($this->data['name'] === $value) {
return;
}
$this->data['name'] = $value;
$this->setModified('name');
}
/**
* Set the value of IsAdmin / is_admin.
*
* Must not be null.
* @param $value int
*/
public function setIsAdmin($value)
{
$this->validateNotNull('IsAdmin', $value);
$this->validateInt('IsAdmin', $value);
if ($this->data['is_admin'] === $value) {
return;
}
$this->data['is_admin'] = $value;
$this->setModified('is_admin');
}
/**
* Set the value of ProviderKey / provider_key.
*
* Must not be null.
* @param $value string
*/
public function setProviderKey($value)
{
$this->validateNotNull('ProviderKey', $value);
$this->validateString('ProviderKey', $value);
if ($this->data['provider_key'] === $value) {
return;
}
$this->data['provider_key'] = $value;
$this->setModified('provider_key');
}
/**
* Set the value of ProviderData / provider_data.
*
* @param $value string
*/
public function setProviderData($value)
{
$this->validateString('ProviderData', $value);
if ($this->data['provider_data'] === $value) {
return;
}
$this->data['provider_data'] = $value;
$this->setModified('provider_data');
}
/**
* Set the value of Language / language.
*
* Must not be null.
* @param $value string
*/
public function setLanguage($value)
{
if ($this->data['language'] === $value) {
return;
}
$this->data['language'] = $value;
$this->setModified('language');
}
/**
* Set the value of PerPage / per_page.
*
* Must not be null.
* @param $value string
*/
public function setPerPage($value)
{
if ($this->data['per_page'] === $value) {
return;
}
$this->data['per_page'] = $value;
$this->setModified('per_page');
}
/**
* @return integer
*/
public function getFinalPerPage()
{
$perPage = $this->getPerPage();
if ($perPage) {
return (integer)$perPage;
}
return (integer)Config::getInstance()->get('php-censor.per_page', 10);
}
}

View file

@ -1,85 +0,0 @@
<?php
/**
* BuildError base store for table: build_error
*/
namespace PHPCensor\Store\Base;
use b8\Database;
use b8\Exception\HttpException;
use PHPCensor\Store;
use PHPCensor\Model\BuildError;
/**
* BuildError Base Store
*/
class BuildErrorStoreBase extends Store
{
protected $tableName = 'build_error';
protected $modelName = '\PHPCensor\Model\BuildError';
protected $primaryKey = 'id';
/**
* Get a BuildError by primary key (Id)
*/
public function getByPrimaryKey($value, $useConnection = 'read')
{
return $this->getById($value, $useConnection);
}
/**
* Get a single BuildError by Id.
* @return null|BuildError
*/
public function getById($value, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{build_error}} WHERE {{id}} = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new BuildError($data);
}
}
return null;
}
/**
* Get multiple BuildError by BuildId.
* @return array
*/
public function getByBuildId($value, $limit = 1000, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{build_error}} WHERE {{build_id}} = :build_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':build_id', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
if ($stmt->execute()) {
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$map = function ($item) {
return new BuildError($item);
};
$rtn = array_map($map, $res);
$count = count($rtn);
return ['items' => $rtn, 'count' => $count];
} else {
return ['items' => [], 'count' => 0];
}
}
}

View file

@ -1,117 +0,0 @@
<?php
/**
* BuildMeta base store for table: build_meta
*/
namespace PHPCensor\Store\Base;
use b8\Database;
use b8\Exception\HttpException;
use PHPCensor\Store;
use PHPCensor\Model\BuildMeta;
/**
* BuildMeta Base Store
*/
class BuildMetaStoreBase extends Store
{
protected $tableName = 'build_meta';
protected $modelName = '\PHPCensor\Model\BuildMeta';
protected $primaryKey = 'id';
/**
* Get a BuildMeta by primary key (Id)
*/
public function getByPrimaryKey($value, $useConnection = 'read')
{
return $this->getById($value, $useConnection);
}
/**
* Get a single BuildMeta by Id.
* @return null|BuildMeta
*/
public function getById($value, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{build_meta}} WHERE {{id}} = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new BuildMeta($data);
}
}
return null;
}
/**
* Get multiple BuildMeta by ProjectId.
* @return array
*/
public function getByProjectId($value, $limit = 1000, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{build_meta}} WHERE {{project_id}} = :project_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':project_id', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
if ($stmt->execute()) {
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$map = function ($item) {
return new BuildMeta($item);
};
$rtn = array_map($map, $res);
$count = count($rtn);
return ['items' => $rtn, 'count' => $count];
} else {
return ['items' => [], 'count' => 0];
}
}
/**
* Get multiple BuildMeta by BuildId.
* @return array
*/
public function getByBuildId($value, $limit = 1000, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{build_meta}} WHERE {{build_id}} = :build_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':build_id', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
if ($stmt->execute()) {
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$map = function ($item) {
return new BuildMeta($item);
};
$rtn = array_map($map, $res);
$count = count($rtn);
return ['items' => $rtn, 'count' => $count];
} else {
return ['items' => [], 'count' => 0];
}
}
}

View file

@ -1,123 +0,0 @@
<?php
/**
* Build base store for table: build
*/
namespace PHPCensor\Store\Base;
use b8\Database;
use b8\Exception\HttpException;
use PHPCensor\Store;
use PHPCensor\Model\Build;
/**
* Build Base Store
*/
class BuildStoreBase extends Store
{
protected $tableName = 'build';
protected $modelName = '\PHPCensor\Model\Build';
protected $primaryKey = 'id';
/**
* Get a Build by primary key (Id)
*/
public function getByPrimaryKey($value, $useConnection = 'read')
{
return $this->getById($value, $useConnection);
}
/**
* Get a single Build by Id.
* @return null|Build
*/
public function getById($value, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{build}} WHERE {{id}} = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new Build($data);
}
}
return null;
}
/**
* Get multiple Build by ProjectId.
* @return array
*/
public function getByProjectId($value, $limit = 1000, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{build}} WHERE {{project_id}} = :project_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':project_id', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
if ($stmt->execute()) {
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$map = function ($item) {
return new Build($item);
};
$rtn = array_map($map, $res);
$count = count($rtn);
return ['items' => $rtn, 'count' => $count];
} else {
return ['items' => [], 'count' => 0];
}
}
/**
* Get multiple Build by Status.
*
* @param $value
* @param int $limit
* @param string $useConnection
*
* @return array
*
* @throws HttpException
*/
public function getByStatus($value, $limit = 1000, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{build}} WHERE {{status}} = :status LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':status', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
if ($stmt->execute()) {
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$map = function ($item) {
return new Build($item);
};
$rtn = array_map($map, $res);
$count = count($rtn);
return ['items' => $rtn, 'count' => $count];
} else {
return ['items' => [], 'count' => 0];
}
}
}

View file

@ -1,90 +0,0 @@
<?php
/**
* ProjectGroup base store for table: project_group
*/
namespace PHPCensor\Store\Base;
use b8\Database;
use b8\Exception\HttpException;
use PHPCensor\Store;
use PHPCensor\Model\ProjectGroup;
/**
* ProjectGroup Base Store
*/
class ProjectGroupStoreBase extends Store
{
protected $tableName = 'project_group';
protected $modelName = '\PHPCensor\Model\ProjectGroup';
protected $primaryKey = 'id';
/**
* Get a ProjectGroup by primary key (Id)
*/
public function getByPrimaryKey($value, $useConnection = 'read')
{
return $this->getById($value, $useConnection);
}
/**
* Get a single ProjectGroup by Id.
*
* @param integer $value
* @param string $useConnection
*
* @return ProjectGroup|null
*
* @throws HttpException
*/
public function getById($value, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{project_group}} WHERE {{id}} = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new ProjectGroup($data);
}
}
return null;
}
/**
* Get a single ProjectGroup by title.
*
* @param integer $value
* @param string $useConnection
*
* @return ProjectGroup|null
*
* @throws HttpException
*/
public function getByTitle($value, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{project_group}} WHERE {{title}} = :title LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':title', $value);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new ProjectGroup($data);
}
}
return null;
}
}

View file

@ -1,117 +0,0 @@
<?php
/**
* Project base store for table: project
*/
namespace PHPCensor\Store\Base;
use b8\Database;
use b8\Exception\HttpException;
use PHPCensor\Store;
use PHPCensor\Model\Project;
/**
* Project Base Store
*/
class ProjectStoreBase extends Store
{
protected $tableName = 'project';
protected $modelName = '\PHPCensor\Model\Project';
protected $primaryKey = 'id';
/**
* Get a Project by primary key (Id)
*/
public function getByPrimaryKey($value, $useConnection = 'read')
{
return $this->getById($value, $useConnection);
}
/**
* Get a single Project by Id.
* @return null|Project
*/
public function getById($value, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{project}} WHERE {{id}} = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new Project($data);
}
}
return null;
}
/**
* Get multiple Project by Title.
* @return array
*/
public function getByTitle($value, $limit = 1000, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{project}} WHERE {{title}} = :title LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':title', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
if ($stmt->execute()) {
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$map = function ($item) {
return new Project($item);
};
$rtn = array_map($map, $res);
$count = count($rtn);
return ['items' => $rtn, 'count' => $count];
} else {
return ['items' => [], 'count' => 0];
}
}
/**
* Get multiple Project by GroupId.
* @return array
*/
public function getByGroupId($value, $limit = 1000, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{project}} WHERE {{group_id}} = :group_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':group_id', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
if ($stmt->execute()) {
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$map = function ($item) {
return new Project($item);
};
$rtn = array_map($map, $res);
$count = count($rtn);
return ['items' => $rtn, 'count' => $count];
} else {
return ['items' => [], 'count' => 0];
}
}
}

View file

@ -1,143 +0,0 @@
<?php
/**
* User base store for table: user
*/
namespace PHPCensor\Store\Base;
use b8\Database;
use b8\Exception\HttpException;
use PHPCensor\Store;
use PHPCensor\Model\User;
/**
* User Base Store
*/
class UserStoreBase extends Store
{
protected $tableName = 'user';
protected $modelName = '\PHPCensor\Model\User';
protected $primaryKey = 'id';
/**
* Get a User by primary key (Id)
*/
public function getByPrimaryKey($value, $useConnection = 'read')
{
return $this->getById($value, $useConnection);
}
/**
* Get a single User by Id.
* @return null|User
*/
public function getById($value, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{user}} WHERE {{id}} = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new User($data);
}
}
return null;
}
/**
*
* Get a single User by Email.
*
* @param string $value
*
* @throws HttpException
*
* @return User
*/
public function getByEmail($value)
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{user}} WHERE {{email}} = :email LIMIT 1';
$stmt = Database::getConnection()->prepareCommon($query);
$stmt->bindValue(':email', $value);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new User($data);
}
}
return null;
}
/**
*
* Get a single User by Email or Name.
*
* @param string $value
*
* @throws HttpException
*
* @return User
*/
public function getByEmailOrName($value)
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{user}} WHERE {{email}} = :value OR {{name}} = :value LIMIT 1';
$stmt = Database::getConnection()->prepareCommon($query);
$stmt->bindValue(':value', $value);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new User($data);
}
}
return null;
}
/**
* Get multiple User by Name.
* @return array
*/
public function getByName($value, $limit = 1000, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{user}} WHERE {{name}} = :name LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':name', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
if ($stmt->execute()) {
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$map = function ($item) {
return new User($item);
};
$rtn = array_map($map, $res);
$count = count($rtn);
return ['items' => $rtn, 'count' => $count];
} else {
return ['items' => [], 'count' => 0];
}
}
}

View file

@ -1,21 +1,81 @@
<?php
/**
* BuildError store for table: build_error
*/
namespace PHPCensor\Store;
use b8\Database;
use PHPCensor\Model\BuildError;
use PHPCensor\Store\Base\BuildErrorStoreBase;
use b8\Exception\HttpException;
use PHPCensor\Store;
/**
* BuildError Store
* @uses PHPCensor\Store\Base\BuildErrorStoreBase
*/
class BuildErrorStore extends BuildErrorStoreBase
class BuildErrorStore extends Store
{
protected $tableName = 'build_error';
protected $modelName = '\PHPCensor\Model\BuildError';
protected $primaryKey = 'id';
/**
* Get a BuildError by primary key (Id)
*/
public function getByPrimaryKey($value, $useConnection = 'read')
{
return $this->getById($value, $useConnection);
}
/**
* Get a single BuildError by Id.
* @return null|BuildError
*/
public function getById($value, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{build_error}} WHERE {{id}} = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new BuildError($data);
}
}
return null;
}
/**
* Get multiple BuildError by BuildId.
* @return array
*/
public function getByBuildId($value, $limit = 1000, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{build_error}} WHERE {{build_id}} = :build_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':build_id', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
if ($stmt->execute()) {
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$map = function ($item) {
return new BuildError($item);
};
$rtn = array_map($map, $res);
$count = count($rtn);
return ['items' => $rtn, 'count' => $count];
} else {
return ['items' => [], 'count' => 0];
}
}
/**
* Get a list of errors for a given build, since a given time.
* @param $buildId

View file

@ -1,24 +1,113 @@
<?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\Store;
use PHPCensor\Store\Base\BuildMetaStoreBase;
use PHPCensor\Store;
use b8\Database;
use PHPCensor\Model\BuildMeta;
use b8\Exception\HttpException;
/**
* BuildMeta Store
* @uses PHPCensor\Store\Base\BuildMetaStoreBase
*/
class BuildMetaStore extends BuildMetaStoreBase
class BuildMetaStore extends Store
{
protected $tableName = 'build_meta';
protected $modelName = '\PHPCensor\Model\BuildMeta';
protected $primaryKey = 'id';
/**
* Get a BuildMeta by primary key (Id)
*/
public function getByPrimaryKey($value, $useConnection = 'read')
{
return $this->getById($value, $useConnection);
}
/**
* Get a single BuildMeta by Id.
* @return null|BuildMeta
*/
public function getById($value, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{build_meta}} WHERE {{id}} = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new BuildMeta($data);
}
}
return null;
}
/**
* Get multiple BuildMeta by ProjectId.
* @return array
*/
public function getByProjectId($value, $limit = 1000, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{build_meta}} WHERE {{project_id}} = :project_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':project_id', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
if ($stmt->execute()) {
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$map = function ($item) {
return new BuildMeta($item);
};
$rtn = array_map($map, $res);
$count = count($rtn);
return ['items' => $rtn, 'count' => $count];
} else {
return ['items' => [], 'count' => 0];
}
}
/**
* Get multiple BuildMeta by BuildId.
* @return array
*/
public function getByBuildId($value, $limit = 1000, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{build_meta}} WHERE {{build_id}} = :build_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':build_id', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
if ($stmt->execute()) {
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$map = function ($item) {
return new BuildMeta($item);
};
$rtn = array_map($map, $res);
$count = count($rtn);
return ['items' => $rtn, 'count' => $count];
} else {
return ['items' => [], 'count' => 0];
}
}
/**
* Only used by an upgrade migration to move errors from build_meta to build_error
*

View file

@ -1,26 +1,122 @@
<?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\Store;
use b8\Database;
use PHPCensor\Model\Build;
use PHPCensor\Store\Base\BuildStoreBase;
use b8\Exception\HttpException;
use PHPCensor\Store;
/**
* Build Store
* @author Dan Cryer <dan@block8.co.uk>
* @package PHPCI
* @subpackage Core
*/
class BuildStore extends BuildStoreBase
* @author Dan Cryer <dan@block8.co.uk>
*/
class BuildStore extends Store
{
protected $tableName = 'build';
protected $modelName = '\PHPCensor\Model\Build';
protected $primaryKey = 'id';
/**
* Get a Build by primary key (Id)
*/
public function getByPrimaryKey($value, $useConnection = 'read')
{
return $this->getById($value, $useConnection);
}
/**
* Get a single Build by Id.
* @return null|Build
*/
public function getById($value, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{build}} WHERE {{id}} = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new Build($data);
}
}
return null;
}
/**
* Get multiple Build by ProjectId.
* @return array
*/
public function getByProjectId($value, $limit = 1000, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{build}} WHERE {{project_id}} = :project_id LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':project_id', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
if ($stmt->execute()) {
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$map = function ($item) {
return new Build($item);
};
$rtn = array_map($map, $res);
$count = count($rtn);
return ['items' => $rtn, 'count' => $count];
} else {
return ['items' => [], 'count' => 0];
}
}
/**
* Get multiple Build by Status.
*
* @param $value
* @param int $limit
* @param string $useConnection
*
* @return array
*
* @throws HttpException
*/
public function getByStatus($value, $limit = 1000, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{build}} WHERE {{status}} = :status LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':status', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
if ($stmt->execute()) {
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$map = function ($item) {
return new Build($item);
};
$rtn = array_map($map, $res);
$count = count($rtn);
return ['items' => $rtn, 'count' => $count];
} else {
return ['items' => [], 'count' => 0];
}
}
/**
* Return an array of the latest builds for a given project.
* @param null $projectId

View file

@ -1,18 +1,83 @@
<?php
/**
* ProjectGroup store for table: project_group
*/
namespace PHPCensor\Store;
use PHPCensor\Store\Base\ProjectGroupStoreBase;
use b8\Database;
use b8\Exception\HttpException;
use PHPCensor\Store;
use PHPCensor\Model\ProjectGroup;
/**
* ProjectGroup Store
* @uses PHPCensor\Store\Base\ProjectGroupStoreBase
*/
class ProjectGroupStore extends ProjectGroupStoreBase
class ProjectGroupStore extends Store
{
// This class has been left blank so that you can modify it - changes in this file will not be overwritten.
protected $tableName = 'project_group';
protected $modelName = '\PHPCensor\Model\ProjectGroup';
protected $primaryKey = 'id';
/**
* Get a ProjectGroup by primary key (Id)
*/
public function getByPrimaryKey($value, $useConnection = 'read')
{
return $this->getById($value, $useConnection);
}
/**
* Get a single ProjectGroup by Id.
*
* @param integer $value
* @param string $useConnection
*
* @return ProjectGroup|null
*
* @throws HttpException
*/
public function getById($value, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{project_group}} WHERE {{id}} = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new ProjectGroup($data);
}
}
return null;
}
/**
* Get a single ProjectGroup by title.
*
* @param integer $value
* @param string $useConnection
*
* @return ProjectGroup|null
*
* @throws HttpException
*/
public function getByTitle($value, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{project_group}} WHERE {{title}} = :title LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':title', $value);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new ProjectGroup($data);
}
}
return null;
}
}

View file

@ -1,26 +1,84 @@
<?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\Store;
use b8\Database;
use PHPCensor\Model\Project;
use PHPCensor\Store\Base\ProjectStoreBase;
use PHPCensor\Store;
use b8\Exception\HttpException;
/**
* Project Store
* @author Dan Cryer <dan@block8.co.uk>
* @package PHPCI
* @subpackage Core
*/
class ProjectStore extends ProjectStoreBase
* @author Dan Cryer <dan@block8.co.uk>
*/
class ProjectStore extends Store
{
protected $tableName = 'project';
protected $modelName = '\PHPCensor\Model\Project';
protected $primaryKey = 'id';
/**
* Get a Project by primary key (Id)
*/
public function getByPrimaryKey($value, $useConnection = 'read')
{
return $this->getById($value, $useConnection);
}
/**
* Get a single Project by Id.
* @return null|Project
*/
public function getById($value, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{project}} WHERE {{id}} = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new Project($data);
}
}
return null;
}
/**
* Get multiple Project by Title.
* @return array
*/
public function getByTitle($value, $limit = 1000, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{project}} WHERE {{title}} = :title LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':title', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
if ($stmt->execute()) {
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$map = function ($item) {
return new Project($item);
};
$rtn = array_map($map, $res);
$count = count($rtn);
return ['items' => $rtn, 'count' => $count];
} else {
return ['items' => [], 'count' => 0];
}
}
/**
* Returns a list of all branch names PHPCI has run builds against.
* @param $projectId

View file

@ -1,23 +1,139 @@
<?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\Store;
use PHPCensor\Store\Base\UserStoreBase;
use PHPCensor\Store;
use b8\Database;
use b8\Exception\HttpException;
use PHPCensor\Model\User;
/**
* User Store
* @author Dan Cryer <dan@block8.co.uk>
* @package PHPCI
* @subpackage Core
*/
class UserStore extends UserStoreBase
* @author Dan Cryer <dan@block8.co.uk>
*/
class UserStore extends Store
{
// This class has been left blank so that you can modify it - changes in this file will not be overwritten.
protected $tableName = 'user';
protected $modelName = '\PHPCensor\Model\User';
protected $primaryKey = 'id';
/**
* Get a User by primary key (Id)
*/
public function getByPrimaryKey($value, $useConnection = 'read')
{
return $this->getById($value, $useConnection);
}
/**
* Get a single User by Id.
* @return null|User
*/
public function getById($value, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{user}} WHERE {{id}} = :id LIMIT 1';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':id', $value);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new User($data);
}
}
return null;
}
/**
*
* Get a single User by Email.
*
* @param string $value
*
* @throws HttpException
*
* @return User
*/
public function getByEmail($value)
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{user}} WHERE {{email}} = :email LIMIT 1';
$stmt = Database::getConnection()->prepareCommon($query);
$stmt->bindValue(':email', $value);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new User($data);
}
}
return null;
}
/**
*
* Get a single User by Email or Name.
*
* @param string $value
*
* @throws HttpException
*
* @return User
*/
public function getByEmailOrName($value)
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{user}} WHERE {{email}} = :value OR {{name}} = :value LIMIT 1';
$stmt = Database::getConnection()->prepareCommon($query);
$stmt->bindValue(':value', $value);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new User($data);
}
}
return null;
}
/**
* Get multiple User by Name.
* @return array
*/
public function getByName($value, $limit = 1000, $useConnection = 'read')
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{user}} WHERE {{name}} = :name LIMIT :limit';
$stmt = Database::getConnection($useConnection)->prepareCommon($query);
$stmt->bindValue(':name', $value);
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
if ($stmt->execute()) {
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$map = function ($item) {
return new User($item);
};
$rtn = array_map($map, $res);
$count = count($rtn);
return ['items' => $rtn, 'count' => $count];
} else {
return ['items' => [], 'count' => 0];
}
}
}

View file

@ -29,7 +29,6 @@ class BuildTest extends \PHPUnit_Framework_TestCase
$build = new Build();
$this->assertTrue($build instanceof \b8\Model);
$this->assertTrue($build instanceof Model);
$this->assertTrue($build instanceof Model\Base\BuildBase);
}
public function testExecute_TestBaseBuildDefaults()

View file

@ -20,16 +20,11 @@ use PHPCensor\Model;
*/
class ProjectTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
}
public function testExecute_TestIsAValidModel()
{
$project = new Project();
$this->assertTrue($project instanceof \b8\Model);
$this->assertTrue($project instanceof Model);
$this->assertTrue($project instanceof Model\Base\ProjectBase);
}
public function testExecute_TestGitDefaultBranch()