Updating base models to ones generated by the new b8framework generator. Now include strict typing, proper commenting and better formatting. Fixes #13

This commit is contained in:
Dan Cryer 2013-05-15 17:25:11 +01:00
commit 505b0c0563
3 changed files with 570 additions and 326 deletions

View file

@ -12,144 +12,146 @@ use b8\Model;
*/
class BuildBase extends Model
{
public static $sleepable= array();
protected $_tableName = 'build';
protected $_modelName = 'Build';
protected $_data = array(
'id' => null,
'project_id' => null,
'commit_id' => null,
'status' => null,
'log' => null,
'branch' => null,
'created' => null,
'started' => null,
'finished' => null,
'plugins' => null,
);
protected $_getters = array(
'id' => 'getId',
'project_id' => 'getProjectId',
'commit_id' => 'getCommitId',
'status' => 'getStatus',
'log' => 'getLog',
'branch' => 'getBranch',
'created' => 'getCreated',
'started' => 'getStarted',
'finished' => 'getFinished',
'plugins' => 'getPlugins',
/**
* @var array
*/
public static $sleepable = array();
'Project' => 'getProject',
/**
* @var string
*/
protected $_tableName = 'build';
);
/**
* @var string
*/
protected $_modelName = 'Build';
protected $_setters = array(
'id' => 'setId',
'project_id' => 'setProjectId',
'commit_id' => 'setCommitId',
'status' => 'setStatus',
'log' => 'setLog',
'branch' => 'setBranch',
'created' => 'setCreated',
'started' => 'setStarted',
'finished' => 'setFinished',
'plugins' => 'setPlugins',
/**
* @var array
*/
protected $_data = array(
'id' => null,
'project_id' => null,
'commit_id' => null,
'status' => null,
'log' => null,
'branch' => null,
'created' => null,
'started' => null,
'finished' => null,
'plugins' => null,
);
'Project' => 'setProject',
);
public $columns = array(
'id' => array(
'type' => 'int',
'length' => '11',
/**
* @var array
*/
protected $_getters = array(
'id' => 'getId',
'project_id' => 'getProjectId',
'commit_id' => 'getCommitId',
'status' => 'getStatus',
'log' => 'getLog',
'branch' => 'getBranch',
'created' => 'getCreated',
'started' => 'getStarted',
'finished' => 'getFinished',
'plugins' => 'getPlugins',
'Project' => 'getProject',
);
'primary_key' => true,
'auto_increment' => true,
),
'project_id' => array(
'type' => 'int',
'length' => '11',
),
'commit_id' => array(
'type' => 'varchar',
'length' => '50',
),
'status' => array(
'type' => 'tinyint',
'length' => '4',
),
'log' => array(
'type' => 'text',
'length' => '',
'nullable' => true,
),
'branch' => array(
'type' => 'varchar',
'length' => '50',
),
'created' => array(
'type' => 'datetime',
'length' => '',
'nullable' => true,
),
'started' => array(
'type' => 'datetime',
'length' => '',
'nullable' => true,
),
'finished' => array(
'type' => 'datetime',
'length' => '',
'nullable' => true,
),
'plugins' => array(
'type' => 'text',
'length' => '',
'nullable' => true,
),
);
public $indexes = array(
'PRIMARY' => array('unique' => true, 'columns' => 'id'),
'project_id' => array('columns' => 'project_id'),
'idx_status' => array('columns' => 'status'),
);
public $foreignKeys = array(
'build_ibfk_1' => array('local_col' => 'project_id', 'update' => 'CASCADE', 'delete' => 'CASCADE', 'table' => 'project', 'col' => 'id'),
);
/**
* @var array
*/
protected $_setters = array(
'id' => 'setId',
'project_id' => 'setProjectId',
'commit_id' => 'setCommitId',
'status' => 'setStatus',
'log' => 'setLog',
'branch' => 'setBranch',
'created' => 'setCreated',
'started' => 'setStarted',
'finished' => 'setFinished',
'plugins' => 'setPlugins',
'Project' => 'setProject',
);
/**
* @var array
*/
public $columns = array(
'id' => array(
'type' => 'int',
'length' => '11',
'primary_key' => true,
'auto_increment' => true,
),
'project_id' => array(
'type' => 'int',
'length' => '11',
),
'commit_id' => array(
'type' => 'varchar',
'length' => '50',
),
'status' => array(
'type' => 'tinyint',
'length' => '4',
),
'log' => array(
'type' => 'text',
'length' => '',
'nullable' => true,
),
'branch' => array(
'type' => 'varchar',
'length' => '50',
),
'created' => array(
'type' => 'datetime',
'length' => '',
'nullable' => true,
),
'started' => array(
'type' => 'datetime',
'length' => '',
'nullable' => true,
),
'finished' => array(
'type' => 'datetime',
'length' => '',
'nullable' => true,
),
'plugins' => array(
'type' => 'text',
'length' => '',
'nullable' => true,
),
);
/**
* @var array
*/
public $indexes = array(
'PRIMARY' => array('unique' => true, 'columns' => 'id'),
'project_id' => array('columns' => 'project_id'),
'idx_status' => array('columns' => 'status'),
);
/**
* @var array
*/
public $foreignKeys = array(
'build_ibfk_1' => array('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'];
@ -158,6 +160,11 @@ class BuildBase extends Model
return $rtn;
}
/**
* Get the value of ProjectId / project_id.
*
* @return int
*/
public function getProjectId()
{
$rtn = $this->_data['project_id'];
@ -166,6 +173,11 @@ class BuildBase extends Model
return $rtn;
}
/**
* Get the value of CommitId / commit_id.
*
* @return string
*/
public function getCommitId()
{
$rtn = $this->_data['commit_id'];
@ -174,6 +186,11 @@ class BuildBase extends Model
return $rtn;
}
/**
* Get the value of Status / status.
*
* @return int
*/
public function getStatus()
{
$rtn = $this->_data['status'];
@ -182,6 +199,11 @@ class BuildBase extends Model
return $rtn;
}
/**
* Get the value of Log / log.
*
* @return string
*/
public function getLog()
{
$rtn = $this->_data['log'];
@ -190,6 +212,11 @@ class BuildBase extends Model
return $rtn;
}
/**
* Get the value of Branch / branch.
*
* @return string
*/
public function getBranch()
{
$rtn = $this->_data['branch'];
@ -198,6 +225,11 @@ class BuildBase extends Model
return $rtn;
}
/**
* Get the value of Created / created.
*
* @return \DateTime
*/
public function getCreated()
{
$rtn = $this->_data['created'];
@ -212,6 +244,11 @@ class BuildBase extends Model
return $rtn;
}
/**
* Get the value of Started / started.
*
* @return \DateTime
*/
public function getStarted()
{
$rtn = $this->_data['started'];
@ -226,6 +263,11 @@ class BuildBase extends Model
return $rtn;
}
/**
* Get the value of Finished / finished.
*
* @return \DateTime
*/
public function getFinished()
{
$rtn = $this->_data['finished'];
@ -240,6 +282,11 @@ class BuildBase extends Model
return $rtn;
}
/**
* Get the value of Plugins / plugins.
*
* @return string
*/
public function getPlugins()
{
$rtn = $this->_data['plugins'];
@ -248,13 +295,17 @@ class BuildBase extends Model
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)
if($this->_data['id'] === $value)
{
return;
}
@ -264,11 +315,17 @@ class BuildBase extends Model
$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)
if($this->_data['project_id'] === $value)
{
return;
}
@ -278,11 +335,17 @@ class BuildBase extends Model
$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)
if($this->_data['commit_id'] === $value)
{
return;
}
@ -292,11 +355,17 @@ class BuildBase extends Model
$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)
if($this->_data['status'] === $value)
{
return;
}
@ -306,11 +375,16 @@ class BuildBase extends Model
$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)
if($this->_data['log'] === $value)
{
return;
}
@ -320,11 +394,17 @@ class BuildBase extends Model
$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)
if($this->_data['branch'] === $value)
{
return;
}
@ -334,11 +414,16 @@ class BuildBase extends Model
$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)
if($this->_data['created'] === $value)
{
return;
}
@ -348,11 +433,16 @@ class BuildBase extends Model
$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)
if($this->_data['started'] === $value)
{
return;
}
@ -362,11 +452,16 @@ class BuildBase extends Model
$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)
if($this->_data['finished'] === $value)
{
return;
}
@ -376,11 +471,16 @@ class BuildBase extends Model
$this->_setModified('finished');
}
/**
* Set the value of Plugins / plugins.
*
* @param $value string
*/
public function setPlugins($value)
{
$this->_validateString('Plugins', $value);
if($this->_data['plugins'] == $value)
if($this->_data['plugins'] === $value)
{
return;
}
@ -390,8 +490,6 @@ class BuildBase extends Model
$this->_setModified('plugins');
}
/**
* Get the Project model for this Build by Id.
*
@ -408,9 +506,23 @@ class BuildBase extends Model
return null;
}
return \b8\Store\Factory::getStore('Project')->getById($key);
$cacheKey = 'Cache.Project.' . $key;
$rtn = $this->registry->get($cacheKey, null);
if(empty($rtn))
{
$rtn = \b8\Store\Factory::getStore('Project')->getById($key);
$this->registry->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?
@ -429,11 +541,14 @@ class BuildBase extends Model
return $this->setProjectId($value);
}
/**
* Set Project - Accepts a Project model.
*
* @param $value \PHPCI\Model\Project
*/
public function setProjectObject(\PHPCI\Model\Project $value)
{
return $this->setProjectId($value->getId());
}
}