* Revert gitlab model.

This commit is contained in:
xiawenlong
2021-11-19 09:33:51 +08:00
parent 8fc6867523
commit 1a5809ae20
2 changed files with 28 additions and 2 deletions

View File

@@ -579,7 +579,7 @@ class gitlabModel extends model
* @access public
* @return array
*/
public function apiGetProjects($gitlabID, $keyword = '', $orderBy, $pager)
public function apiGetProjectsPager($gitlabID, $keyword = '', $orderBy, $pager)
{
$gitlab = $this->getByID($gitlabID);
if(!$gitlab) return array();
@@ -600,6 +600,32 @@ class gitlabModel extends model
return array('pager' => $pager, 'projects' => json_decode($result['body']));
}
/**
* Get projects of one gitlab.
*
* @param int $gitlabID
* @access public
* @return array
*/
public function apiGetProjects($gitlabID)
{
$gitlab = $this->getByID($gitlabID);
if(!$gitlab) return array();
$host = rtrim($gitlab->url, '/');
$host .= '/api/v4/projects';
$allResults = array();
for($page = 1; true; $page++)
{
$results = json_decode(commonModel::http($host . "?private_token={$gitlab->token}&simple=true&page={$page}&per_page=100"));
if(!empty($results)) $allResults = array_merge($allResults, $results);
if(count($results)<100 or $page > 10) break;
}
return $allResults;
}
/**
* Create a gitab project by api.
*