From e61ce203a34cebaa83f946f61e454bcd3b9661be Mon Sep 17 00:00:00 2001 From: Dan Cryer Date: Fri, 9 Oct 2015 09:38:55 +0100 Subject: [PATCH] Docblocks --- PHPCI/Controller/GroupController.php | 16 ++++++++++++++++ PHPCI/Controller/HomeController.php | 4 ++++ PHPCI/Store/Base/BuildMetaStoreBase.php | 15 +++++++++++++++ PHPCI/Store/Base/BuildStoreBase.php | 15 +++++++++++++++ PHPCI/Store/Base/ProjectGroupStoreBase.php | 7 +++++++ PHPCI/Store/Base/ProjectStoreBase.php | 15 +++++++++++++++ PHPCI/Store/Base/UserStoreBase.php | 15 +++++++++++++++ PHPCI/Worker/BuildWorker.php | 12 +++++++++++- 8 files changed, 98 insertions(+), 1 deletion(-) diff --git a/PHPCI/Controller/GroupController.php b/PHPCI/Controller/GroupController.php index cc4b4c51..898f9e41 100644 --- a/PHPCI/Controller/GroupController.php +++ b/PHPCI/Controller/GroupController.php @@ -28,11 +28,17 @@ class GroupController extends Controller */ protected $groupStore; + /** + * Set up this controller. + */ public function init() { $this->groupStore = b8\Store\Factory::getStore('ProjectGroup'); } + /** + * List project groups. + */ public function index() { $this->requireAdmin(); @@ -53,6 +59,11 @@ class GroupController extends Controller $this->view->groups = $groups; } + /** + * Add or edit a project group. + * @param null $groupId + * @return void|b8\Http\Response\RedirectResponse + */ public function edit($groupId = null) { $this->requireAdmin(); @@ -91,6 +102,11 @@ class GroupController extends Controller $this->view->form = $form; } + /** + * Delete a project group. + * @param $groupId + * @return b8\Http\Response\RedirectResponse + */ public function delete($groupId) { $this->requireAdmin(); diff --git a/PHPCI/Controller/HomeController.php b/PHPCI/Controller/HomeController.php index 1b0c60aa..4241d324 100644 --- a/PHPCI/Controller/HomeController.php +++ b/PHPCI/Controller/HomeController.php @@ -144,6 +144,10 @@ class HomeController extends \PHPCI\Controller return $view->render(); } + /** + * Get a summary of the project groups we have, and what projects they have in them. + * @return array + */ protected function getGroupInfo() { $rtn = array(); diff --git a/PHPCI/Store/Base/BuildMetaStoreBase.php b/PHPCI/Store/Base/BuildMetaStoreBase.php index 6c4cfc15..52665d79 100644 --- a/PHPCI/Store/Base/BuildMetaStoreBase.php +++ b/PHPCI/Store/Base/BuildMetaStoreBase.php @@ -20,11 +20,18 @@ class BuildMetaStoreBase extends Store protected $modelName = '\PHPCI\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)) { @@ -44,6 +51,10 @@ class BuildMetaStoreBase extends Store return null; } + /** + * Get multiple BuildMeta by ProjectId. + * @return array + */ public function getByProjectId($value, $limit = 1000, $useConnection = 'read') { if (is_null($value)) { @@ -72,6 +83,10 @@ class BuildMetaStoreBase extends Store } } + /** + * Get multiple BuildMeta by BuildId. + * @return array + */ public function getByBuildId($value, $limit = 1000, $useConnection = 'read') { if (is_null($value)) { diff --git a/PHPCI/Store/Base/BuildStoreBase.php b/PHPCI/Store/Base/BuildStoreBase.php index 89d3a82f..b8b49cb7 100644 --- a/PHPCI/Store/Base/BuildStoreBase.php +++ b/PHPCI/Store/Base/BuildStoreBase.php @@ -20,11 +20,18 @@ class BuildStoreBase extends Store protected $modelName = '\PHPCI\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)) { @@ -44,6 +51,10 @@ class BuildStoreBase extends Store return null; } + /** + * Get multiple Build by ProjectId. + * @return array + */ public function getByProjectId($value, $limit = 1000, $useConnection = 'read') { if (is_null($value)) { @@ -72,6 +83,10 @@ class BuildStoreBase extends Store } } + /** + * Get multiple Build by Status. + * @return array + */ public function getByStatus($value, $limit = 1000, $useConnection = 'read') { if (is_null($value)) { diff --git a/PHPCI/Store/Base/ProjectGroupStoreBase.php b/PHPCI/Store/Base/ProjectGroupStoreBase.php index 5b2730ea..c7cd8772 100644 --- a/PHPCI/Store/Base/ProjectGroupStoreBase.php +++ b/PHPCI/Store/Base/ProjectGroupStoreBase.php @@ -20,11 +20,18 @@ class ProjectGroupStoreBase extends Store protected $modelName = '\PHPCI\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. + * @return null|ProjectGroup + */ public function getById($value, $useConnection = 'read') { if (is_null($value)) { diff --git a/PHPCI/Store/Base/ProjectStoreBase.php b/PHPCI/Store/Base/ProjectStoreBase.php index c764238d..1e2bf65b 100644 --- a/PHPCI/Store/Base/ProjectStoreBase.php +++ b/PHPCI/Store/Base/ProjectStoreBase.php @@ -20,11 +20,18 @@ class ProjectStoreBase extends Store protected $modelName = '\PHPCI\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)) { @@ -44,6 +51,10 @@ class ProjectStoreBase extends Store return null; } + /** + * Get multiple Project by Title. + * @return array + */ public function getByTitle($value, $limit = 1000, $useConnection = 'read') { if (is_null($value)) { @@ -72,6 +83,10 @@ class ProjectStoreBase extends Store } } + /** + * Get multiple Project by GroupId. + * @return array + */ public function getByGroupId($value, $limit = 1000, $useConnection = 'read') { if (is_null($value)) { diff --git a/PHPCI/Store/Base/UserStoreBase.php b/PHPCI/Store/Base/UserStoreBase.php index 90d60cb4..c1c6cdf7 100644 --- a/PHPCI/Store/Base/UserStoreBase.php +++ b/PHPCI/Store/Base/UserStoreBase.php @@ -20,11 +20,18 @@ class UserStoreBase extends Store protected $modelName = '\PHPCI\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)) { @@ -44,6 +51,10 @@ class UserStoreBase extends Store return null; } + /** + * Get a single User by Email. + * @return null|User + */ public function getByEmail($value, $useConnection = 'read') { if (is_null($value)) { @@ -63,6 +74,10 @@ class UserStoreBase extends Store return null; } + /** + * Get a single User by Name. + * @return null|User + */ public function getByName($value, $useConnection = 'read') { if (is_null($value)) { diff --git a/PHPCI/Worker/BuildWorker.php b/PHPCI/Worker/BuildWorker.php index 37d2bc20..92ee4ced 100644 --- a/PHPCI/Worker/BuildWorker.php +++ b/PHPCI/Worker/BuildWorker.php @@ -171,6 +171,10 @@ class BuildWorker $this->run = false; } + /** + * Checks if this worker has done the amount of jobs it is allowed to do, and if so tells it to stop + * after this job completes. + */ protected function checkJobLimit() { // Make sure we don't run more than maxJobs jobs on this worker: @@ -181,11 +185,17 @@ class BuildWorker } } + /** + * Checks that the job received is actually from PHPCI, and has a valid type. + * @param Job $job + * @param $jobData + * @return bool + */ protected function verifyJob(Job $job, $jobData) { if (empty($jobData) || !is_array($jobData)) { // Probably not from PHPCI. - $this->pheanstalk->release($job); + $this->pheanstalk->delete($job); return false; }