* Add funcs for getting gitlab api url with access_token.
This commit is contained in:
+32
-1
@@ -10,6 +10,11 @@
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
|
||||
|
||||
/* enable JMESPath */
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
|
||||
class gitlabModel extends model
|
||||
{
|
||||
/**
|
||||
@@ -155,5 +160,31 @@ class gitlabModel extends model
|
||||
$allResults = $allResults + $results;
|
||||
}
|
||||
return $allResults;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get gitlab api base url with access_token
|
||||
*
|
||||
* @param int $id
|
||||
* @access public
|
||||
* @return string gitlab api base url with access_token
|
||||
*/
|
||||
public function getGitlabBaseApiUrl($id)
|
||||
{
|
||||
$gitlab = $this->getByID($id);
|
||||
if(!$gitlab) return array();
|
||||
$gitlab_url = rtrim($gitlab->url, '/').'/api/v4%s'."?private_token={$gitlab->token}";
|
||||
return $gitlab_url;
|
||||
}
|
||||
|
||||
|
||||
public function getHooksOfProject($gitlab_id, $project_id)
|
||||
{
|
||||
$host = $this->getGitlabBaseApiUrl($gitlab_id);
|
||||
$api_path = sprintf('/projects/%s/hooks', $project_id);
|
||||
$host = sprintf($host, $api_path);
|
||||
$api_json = commonModel::http($host);
|
||||
return $api_json;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user