diff --git a/module/gitea/control.php b/module/gitea/control.php index de20a6d6e9..ad534c70f0 100644 --- a/module/gitea/control.php +++ b/module/gitea/control.php @@ -92,7 +92,7 @@ class gitea extends control */ public function view($giteaID) { - $gitea = $this->gitea->getByID($giteaID); + $gitea = $this->gitea->fetchByID($giteaID); $this->view->title = $this->lang->gitea->common . $this->lang->colon . $this->lang->gitea->view; $this->view->gitea = $gitea; @@ -111,7 +111,7 @@ class gitea extends control */ public function edit($giteaID) { - $oldGitea = $this->gitea->getByID($giteaID); + $oldGitea = $this->gitea->fetchByID($giteaID); if($_POST) { @@ -120,7 +120,7 @@ class gitea extends control $this->loadModel('pipeline')->update($giteaID, $gitea); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - $gitea = $this->gitea->getByID($giteaID); + $gitea = $this->gitea->fetchByID($giteaID); $actionID = $this->loadModel('action')->create('gitea', $giteaID, 'edited'); $changes = common::createChanges($oldGitea, $gitea); $this->action->logHistory($actionID, $changes); @@ -143,7 +143,7 @@ class gitea extends control */ public function delete($giteaID) { - $oldGitea = $this->loadModel('pipeline')->getByID($giteaID); + $oldGitea = $this->loadModel('pipeline')->fetchByID($giteaID); $actionID = $this->pipeline->deleteByObject($giteaID, 'gitea'); if(!$actionID) { @@ -152,7 +152,7 @@ class gitea extends control return $this->send($response); } - $gitea = $this->pipeline->getByID($giteaID); + $gitea = $this->pipeline->fetchByID($giteaID); $changes = common::createChanges($oldGitea, $gitea); $this->loadModel('action')->logHistory($actionID, $changes); diff --git a/module/gitea/model.php b/module/gitea/model.php index 79ad0951d1..f6af4514d1 100644 --- a/module/gitea/model.php +++ b/module/gitea/model.php @@ -20,18 +20,6 @@ class giteaModel extends model public $developerAccess = 30; public $maintainerAccess = 40; - /** - * Get a gitea by id. - * - * @param int $id - * @access public - * @return object - */ - public function getByID($id) - { - return $this->loadModel('pipeline')->getByID($id); - } - /** * Get gitea list. * @@ -68,7 +56,7 @@ class giteaModel extends model */ public function getApiRoot($giteaID, $sudo = true) { - $gitea = $this->getByID($giteaID); + $gitea = $this->fetchByID($giteaID); if(!$gitea) return ''; $sudoParam = ''; @@ -331,7 +319,7 @@ class giteaModel extends model $project->http_url_to_repo = $project->html_url; $project->name_with_namespace = $project->full_name; - $gitea = $this->getByID($giteaID); + $gitea = $this->fetchByID($giteaID); $oauth = "oauth2:{$gitea->token}@"; $project->tokenCloneUrl = preg_replace('/(http(s)?:\/\/)/', "\$1$oauth", $project->html_url); $project->tokenCloneUrl = str_replace(array('https://', 'http://'), strstr($url, ':', true) . '://', $project->tokenCloneUrl); @@ -525,7 +513,7 @@ class giteaModel extends model $branch = json_decode(commonModel::http($url)); if($branch) { - $gitea = $this->getByID($giteaID); + $gitea = $this->fetchByID($giteaID); $branch->web_url = "{$gitea->url}/$project/src/branch/$branchName"; } diff --git a/module/gitea/test/gitea.class.php b/module/gitea/test/gitea.class.php index 52cec105a3..f20e7bff9d 100644 --- a/module/gitea/test/gitea.class.php +++ b/module/gitea/test/gitea.class.php @@ -10,20 +10,6 @@ class giteaTest $this->gitea = $this->tester->loadModel('gitea'); } - /** - * Get by id. - * - * @param int $id - * @access public - * @return object - */ - public function getByID($id) - { - $gitea = $this->gitea->getByID($id); - if(empty($gitea)) return 0; - return $gitea; - } - /** * Get gitea list. * @@ -78,7 +64,7 @@ class giteaTest return key($errors); } - return $this->gitea->getById($giteaID); + return $this->gitea->fetchByID($giteaID); } /** @@ -97,6 +83,6 @@ class giteaTest return key($errors); } - return $this->gitea->getById($id); + return $this->gitea->fetchByID($id); } } diff --git a/module/gitea/test/model/getbyid.php b/module/gitea/test/model/getbyid.php deleted file mode 100755 index a8c9cb4f34..0000000000 --- a/module/gitea/test/model/getbyid.php +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env php -gitById(); -cid=1 -pid=1 - -使用存在的ID >> 4 -使用空的ID >> 0 -使用不存在的ID >> 0 - -*/ - -$gitea = new giteaTest(); - -$giteaID = 4; -r($gitea->getById($giteaID)) && p('id') && e('4'); // 使用存在的ID - -$giteaID = 0; -r($gitea->getById($giteaID)) && p() && e(0); // 使用空的ID - -$giteaID = 111; -r($gitea->getById($giteaID)) && p() && e(0); // 使用不存在的ID - diff --git a/module/gogs/control.php b/module/gogs/control.php index 6fb29e2b60..8c44a3d776 100644 --- a/module/gogs/control.php +++ b/module/gogs/control.php @@ -90,7 +90,7 @@ class gogs extends control */ public function view($gogsID) { - $gogs = $this->gogs->getByID($gogsID); + $gogs = $this->gogs->fetchByID($gogsID); $this->view->title = $this->lang->gogs->common . $this->lang->colon . $this->lang->gogs->view; $this->view->gogs = $gogs; @@ -109,7 +109,7 @@ class gogs extends control */ public function edit($gogsID) { - $oldGogs = $this->gogs->getByID($gogsID); + $oldGogs = $this->gogs->fetchByID($gogsID); if($_POST) { @@ -118,7 +118,7 @@ class gogs extends control $this->gogs->update($gogsID, $gogs); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - $gogs = $this->gogs->getByID($gogsID); + $gogs = $this->gogs->fetchByID($gogsID); $actionID = $this->loadModel('action')->create('gogs', $gogsID, 'edited'); $changes = common::createChanges($oldGogs, $gogs); $this->action->logHistory($actionID, $changes); @@ -141,7 +141,7 @@ class gogs extends control */ public function delete($gogsID) { - $oldGogs = $this->loadModel('pipeline')->getByID($gogsID); + $oldGogs = $this->loadModel('pipeline')->fetchByID($gogsID); $actionID = $this->pipeline->deleteByObject($gogsID, 'gogs'); if(!$actionID) { @@ -151,7 +151,7 @@ class gogs extends control return $this->send($response); } - $gogs = $this->pipeline->getByID($gogsID); + $gogs = $this->pipeline->fetchByID($gogsID); $changes = common::createChanges($oldGogs, $gogs); $this->loadModel('action')->logHistory($actionID, $changes); diff --git a/module/gogs/model.php b/module/gogs/model.php index a825b333ce..74d31775b2 100644 --- a/module/gogs/model.php +++ b/module/gogs/model.php @@ -12,18 +12,6 @@ class gogsModel extends model { - /** - * Get a gogs by id. - * - * @param int $id - * @access public - * @return object - */ - public function getByID($id) - { - return $this->loadModel('pipeline')->getByID($id); - } - /** * Get gogs list. * @@ -59,7 +47,7 @@ class gogsModel extends model */ public function getApiRoot($gogsID) { - $gogs = $this->getByID($gogsID); + $gogs = $this->fetchByID($gogsID); if(!$gogs) return ''; return rtrim($gogs->url, '/') . '/api/v1%s' . "?token={$gogs->token}"; @@ -290,8 +278,7 @@ class gogsModel extends model $project->http_url_to_repo = $project->html_url; $project->name_with_namespace = $project->full_name; - $gogs = $this->getByID($gogsID); - $oauth = "{$gogs->token}@"; + $gogs = $this->fetchByID($gogsID); $project->tokenCloneUrl = preg_replace('/(http(s)?:\/\/)/', '${1}' . $gogs->token . '@', $project->html_url); } @@ -463,7 +450,7 @@ class gogsModel extends model $branch = json_decode(commonModel::http($url)); if($branch) { - $gogs = $this->getByID($gogsID); + $gogs = $this->fetchByID($gogsID); $branch->web_url = "{$gogs->url}/$project/src/$branchName"; } diff --git a/module/gogs/test/gogs.class.php b/module/gogs/test/gogs.class.php index 68d7c74435..2470e131cd 100644 --- a/module/gogs/test/gogs.class.php +++ b/module/gogs/test/gogs.class.php @@ -10,20 +10,6 @@ class gogsTest $this->gogs = $this->tester->loadModel('gogs'); } - /** - * Get by id. - * - * @param int $id - * @access public - * @return object - */ - public function getByID($id) - { - $gogs = $this->gogs->getByID($id); - if(empty($gogs)) return 0; - return $gogs; - } - /** * Get gogs list. * @@ -64,7 +50,7 @@ class gogsTest return key($errors); } - return $this->gogs->getById($gogsID); + return $this->gogs->fetchByID($gogsID); } /** @@ -83,6 +69,6 @@ class gogsTest return key($errors); } - return $this->gogs->getById($id); + return $this->gogs->fetchByID($id); } } diff --git a/module/gogs/test/model/getbyid.php b/module/gogs/test/model/getbyid.php deleted file mode 100755 index 30ab1220f6..0000000000 --- a/module/gogs/test/model/getbyid.php +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env php -gitById(); -cid=1 -pid=1 - -使用存在的ID >> 5 -使用空的ID >> 0 -使用不存在的ID >> 0 - -*/ - -$gogs = new gogsTest(); - -$gogsID = 5; -r($gogs->getById($gogsID)) && p('id') && e('5'); // 使用存在的ID - -$gogsID = 0; -r($gogs->getById($gogsID)) && p() && e(0); // 使用空的ID - -$gogsID = 111; -r($gogs->getById($gogsID)) && p() && e(0); // 使用不存在的ID - diff --git a/module/instance/control.php b/module/instance/control.php index dd75f81b6e..328a154a96 100644 --- a/module/instance/control.php +++ b/module/instance/control.php @@ -46,7 +46,7 @@ class instance extends control } else { - $instance = $this->loadModel('gitea')->getByID($id); + $instance = $this->loadModel('gitea')->fetchByID($id); $instance->status = ''; $instance->source = 'user'; $instance->externalID = $instance->id;