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
parent 20bb2e7a10
commit 505b0c0563
3 changed files with 578 additions and 334 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());
}
}

View file

@ -12,95 +12,109 @@ use b8\Model;
*/
class ProjectBase extends Model
{
public static $sleepable= array();
protected $_tableName = 'project';
protected $_modelName = 'Project';
protected $_data = array(
'id' => null,
'title' => null,
'reference' => null,
'git_key' => null,
'type' => null,
'token' => null,
);
protected $_getters = array(
'id' => 'getId',
'title' => 'getTitle',
'reference' => 'getReference',
'git_key' => 'getGitKey',
'type' => 'getType',
'token' => 'getToken',
);
protected $_setters = array(
'id' => 'setId',
'title' => 'setTitle',
'reference' => 'setReference',
'git_key' => 'setGitKey',
'type' => 'setType',
'token' => 'setToken',
);
public $columns = array(
'id' => array(
'type' => 'int',
'length' => '11',
'primary_key' => true,
'auto_increment' => true,
),
'title' => array(
'type' => 'varchar',
'length' => '250',
),
'reference' => array(
'type' => 'varchar',
'length' => '250',
),
'git_key' => array(
'type' => 'text',
'length' => '',
),
'type' => array(
'type' => 'varchar',
'length' => '50',
),
'token' => array(
'type' => 'varchar',
'length' => '50',
'nullable' => true,
),
);
public $indexes = array(
'PRIMARY' => array('unique' => true, 'columns' => 'id'),
);
public $foreignKeys = array(
);
/**
* @var array
*/
public static $sleepable = array();
/**
* @var string
*/
protected $_tableName = 'project';
/**
* @var string
*/
protected $_modelName = 'Project';
/**
* @var array
*/
protected $_data = array(
'id' => null,
'title' => null,
'reference' => null,
'git_key' => null,
'type' => null,
'token' => null,
);
/**
* @var array
*/
protected $_getters = array(
'id' => 'getId',
'title' => 'getTitle',
'reference' => 'getReference',
'git_key' => 'getGitKey',
'type' => 'getType',
'token' => 'getToken',
);
/**
* @var array
*/
protected $_setters = array(
'id' => 'setId',
'title' => 'setTitle',
'reference' => 'setReference',
'git_key' => 'setGitKey',
'type' => 'setType',
'token' => 'setToken',
);
/**
* @var array
*/
public $columns = array(
'id' => array(
'type' => 'int',
'length' => '11',
'primary_key' => true,
'auto_increment' => true,
),
'title' => array(
'type' => 'varchar',
'length' => '250',
),
'reference' => array(
'type' => 'varchar',
'length' => '250',
),
'git_key' => array(
'type' => 'text',
'length' => '',
),
'type' => array(
'type' => 'varchar',
'length' => '50',
),
'token' => array(
'type' => 'varchar',
'length' => '50',
'nullable' => true,
),
);
/**
* @var array
*/
public $indexes = array(
'PRIMARY' => array('unique' => true, 'columns' => 'id'),
);
/**
* @var array
*/
public $foreignKeys = array(
);
/**
* Get the value of Id / id.
*
* @return int
*/
public function getId()
{
$rtn = $this->_data['id'];
@ -109,6 +123,11 @@ class ProjectBase extends Model
return $rtn;
}
/**
* Get the value of Title / title.
*
* @return string
*/
public function getTitle()
{
$rtn = $this->_data['title'];
@ -117,6 +136,11 @@ class ProjectBase extends Model
return $rtn;
}
/**
* Get the value of Reference / reference.
*
* @return string
*/
public function getReference()
{
$rtn = $this->_data['reference'];
@ -125,6 +149,11 @@ class ProjectBase extends Model
return $rtn;
}
/**
* Get the value of GitKey / git_key.
*
* @return string
*/
public function getGitKey()
{
$rtn = $this->_data['git_key'];
@ -133,6 +162,11 @@ class ProjectBase extends Model
return $rtn;
}
/**
* Get the value of Type / type.
*
* @return string
*/
public function getType()
{
$rtn = $this->_data['type'];
@ -141,6 +175,11 @@ class ProjectBase extends Model
return $rtn;
}
/**
* Get the value of Token / token.
*
* @return string
*/
public function getToken()
{
$rtn = $this->_data['token'];
@ -149,13 +188,17 @@ class ProjectBase 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;
}
@ -165,11 +208,17 @@ class ProjectBase extends Model
$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)
if($this->_data['title'] === $value)
{
return;
}
@ -179,11 +228,17 @@ class ProjectBase extends Model
$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)
if($this->_data['reference'] === $value)
{
return;
}
@ -193,11 +248,17 @@ class ProjectBase extends Model
$this->_setModified('reference');
}
/**
* Set the value of GitKey / git_key.
*
* Must not be null.
* @param $value string
*/
public function setGitKey($value)
{
$this->_validateNotNull('GitKey', $value);
$this->_validateString('GitKey', $value);
if($this->_data['git_key'] == $value)
if($this->_data['git_key'] === $value)
{
return;
}
@ -207,11 +268,17 @@ class ProjectBase extends Model
$this->_setModified('git_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)
if($this->_data['type'] === $value)
{
return;
}
@ -221,11 +288,16 @@ class ProjectBase extends Model
$this->_setModified('type');
}
/**
* Set the value of Token / token.
*
* @param $value string
*/
public function setToken($value)
{
$this->_validateString('Token', $value);
if($this->_data['token'] == $value)
if($this->_data['token'] === $value)
{
return;
}
@ -235,10 +307,6 @@ class ProjectBase extends Model
$this->_setModified('token');
}
/**
* Get Build models by ProjectId for this Project.
*

View file

@ -12,85 +12,102 @@ use b8\Model;
*/
class UserBase extends Model
{
public static $sleepable= array();
protected $_tableName = 'user';
protected $_modelName = 'User';
protected $_data = array(
'id' => null,
'email' => null,
'hash' => null,
'is_admin' => null,
'name' => null,
);
protected $_getters = array(
'id' => 'getId',
'email' => 'getEmail',
'hash' => 'getHash',
'is_admin' => 'getIsAdmin',
'name' => 'getName',
);
protected $_setters = array(
'id' => 'setId',
'email' => 'setEmail',
'hash' => 'setHash',
'is_admin' => 'setIsAdmin',
'name' => 'setName',
);
public $columns = array(
'id' => array(
'type' => 'int',
'length' => '11',
'primary_key' => true,
'auto_increment' => true,
),
'email' => array(
'type' => 'varchar',
'length' => '250',
),
'hash' => array(
'type' => 'varchar',
'length' => '250',
),
'is_admin' => array(
'type' => 'tinyint',
'length' => '1',
),
'name' => array(
'type' => 'varchar',
'length' => '250',
),
);
public $indexes = array(
'PRIMARY' => array('unique' => true, 'columns' => 'id'),
'idx_email' => array('unique' => true, 'columns' => 'email'),
);
public $foreignKeys = array(
);
/**
* @var array
*/
public static $sleepable = array();
/**
* @var string
*/
protected $_tableName = 'user';
/**
* @var string
*/
protected $_modelName = 'User';
/**
* @var array
*/
protected $_data = array(
'id' => null,
'email' => null,
'hash' => null,
'is_admin' => null,
'name' => null,
);
/**
* @var array
*/
protected $_getters = array(
'id' => 'getId',
'email' => 'getEmail',
'hash' => 'getHash',
'is_admin' => 'getIsAdmin',
'name' => 'getName',
);
/**
* @var array
*/
protected $_setters = array(
'id' => 'setId',
'email' => 'setEmail',
'hash' => 'setHash',
'is_admin' => 'setIsAdmin',
'name' => 'setName',
);
/**
* @var array
*/
public $columns = array(
'id' => array(
'type' => 'int',
'length' => '11',
'primary_key' => true,
'auto_increment' => true,
),
'email' => array(
'type' => 'varchar',
'length' => '250',
),
'hash' => array(
'type' => 'varchar',
'length' => '250',
),
'is_admin' => array(
'type' => 'tinyint',
'length' => '1',
),
'name' => array(
'type' => 'varchar',
'length' => '250',
),
);
/**
* @var array
*/
public $indexes = array(
'PRIMARY' => array('unique' => true, 'columns' => 'id'),
'idx_email' => array('unique' => true, 'columns' => 'email'),
);
/**
* @var array
*/
public $foreignKeys = array(
);
/**
* Get the value of Id / id.
*
* @return int
*/
public function getId()
{
$rtn = $this->_data['id'];
@ -99,6 +116,11 @@ class UserBase extends Model
return $rtn;
}
/**
* Get the value of Email / email.
*
* @return string
*/
public function getEmail()
{
$rtn = $this->_data['email'];
@ -107,6 +129,11 @@ class UserBase extends Model
return $rtn;
}
/**
* Get the value of Hash / hash.
*
* @return string
*/
public function getHash()
{
$rtn = $this->_data['hash'];
@ -115,6 +142,11 @@ class UserBase extends Model
return $rtn;
}
/**
* Get the value of IsAdmin / is_admin.
*
* @return int
*/
public function getIsAdmin()
{
$rtn = $this->_data['is_admin'];
@ -123,6 +155,11 @@ class UserBase extends Model
return $rtn;
}
/**
* Get the value of Name / name.
*
* @return string
*/
public function getName()
{
$rtn = $this->_data['name'];
@ -131,13 +168,17 @@ class UserBase 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;
}
@ -147,11 +188,17 @@ class UserBase extends Model
$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)
if($this->_data['email'] === $value)
{
return;
}
@ -161,11 +208,17 @@ class UserBase extends Model
$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)
if($this->_data['hash'] === $value)
{
return;
}
@ -175,11 +228,17 @@ class UserBase extends Model
$this->_setModified('hash');
}
/**
* 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)
if($this->_data['is_admin'] === $value)
{
return;
}
@ -189,11 +248,17 @@ class UserBase extends Model
$this->_setModified('is_admin');
}
/**
* 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)
if($this->_data['name'] === $value)
{
return;
}
@ -203,8 +268,4 @@ class UserBase extends Model
$this->_setModified('name');
}
}