/**
  * Get GitLab project ID.
  *
  * @return bool|null
  */
 public function get_gitlab_id()
 {
     $id = null;
     $response = $this->get_transient('projects');
     if (!$response) {
         self::$method = 'projects';
         $response = $this->api('/projects');
         if (empty($response)) {
             $id = rtrim(urlencode($this->type->slug), '.php');
             return $id;
         }
     }
     foreach ($response as $project) {
         if ($this->type->repo === $project->name) {
             $id = $project->id;
             $this->set_transient('projects', $response);
         }
     }
     return $id;
 }
Exemple #2
0
 /**
  * Get GitLab project ID.
  *
  * @return bool|null
  */
 public function get_gitlab_id()
 {
     $id = null;
     $response = isset($this->response['projects']) ? $this->response['projects'] : false;
     if (!$response) {
         self::$method = 'projects';
         $response = $this->api('/projects');
         if (empty($response)) {
             $id = urlencode($this->type->owner . '/' . $this->type->repo);
             return $id;
         }
     }
     foreach ($response as $project) {
         if ($this->type->repo === $project->path) {
             $id = $project->id;
             $this->set_transient('projects', $response);
             break;
         }
     }
     return $id;
 }
 /**
  * Get GitLab project ID and project meta.
  *
  * @return string|int
  */
 public function get_gitlab_id()
 {
     $id = null;
     $response = isset($this->response['project_id']) ? $this->response['project_id'] : false;
     if (!$response) {
         self::$method = 'projects';
         $response = $this->api('/projects?per_page=100');
         foreach ((array) $response as $project) {
             if ($this->type->repo === $project->path) {
                 $id = $project->id;
                 $this->set_transient('project_id', $id);
                 $this->set_transient('project', $project);
                 return $id;
             }
         }
         if (empty($response)) {
             $id = urlencode($this->type->owner . '/' . $this->type->repo);
             return $id;
         }
     }
     return $response;
 }