示例#1
0
 public function getProject($key)
 {
     $data = $this->get("project/{$key}");
     if (!isset($data['id'])) {
         return null;
     } else {
         return Project::populate($this, $data);
     }
 }
示例#2
0
 /**
  * @param Project $project
  * @param array $data
  * @param bool $loadCustomFields
  * @return Issue
  */
 public static function populate(Project $project, $data, $loadCustomFields = false)
 {
     if (!is_array($data) || !isset($data['id'])) {
         return null;
     }
     $issue = new self();
     $issue->_project = $project;
     $issue->id = (int) $data['id'];
     $issue->_key = $data['key'];
     $issue->summary = $data['fields']['summary'];
     $issue->status = Status::get($data['fields']['status']);
     $issue->priority = Priority::get($data['fields']['priority']);
     $issue->description = $data['fields']['description'];
     $issue->issueType = $project->getIssueType($data['fields']['issuetype']['name']);
     $issue->components = ArrayHelper::index($data['fields']['components'], 'name');
     $issue->timespent = $data['fields']['timespent'];
     $issue->created = strtotime($data['fields']['created']);
     $issue->customFields = [];
     if (isset($data['fields']['parent'])) {
         $issue->parent = self::populate($project, $data['fields']['parent'], $loadCustomFields);
     }
     if ($loadCustomFields) {
         foreach ($issue->issueType->getCustomFieldsMap() as $name => $id) {
             if (isset($data['fields']['customfield_' . $id])) {
                 $issue->customFields[$name] = $data['fields']['customfield_' . $id];
             }
         }
     }
     return $issue;
 }