getKey() public method

Gets issue key (YOURPROJ-123).
public getKey ( ) : string
return string
Example #1
0
 /**
  * Creates backports issues.
  *
  * @param Issue   $issue          Issue.
  * @param string  $project_key    Project key.
  * @param string  $link_name      Link name.
  * @param integer $link_direction Link direction.
  * @param array   $component_ids  Component IDs.
  *
  * @return string
  * @throws \RuntimeException When failed to create an issue.
  * @throws \InvalidArgumentException When link direction isn't valid.
  */
 public function createLinkedIssue(Issue $issue, $project_key, $link_name, $link_direction, array $component_ids)
 {
     $create_fields = array('description' => 'See ' . $issue->getKey() . '.', 'components' => array());
     foreach ($this->_copyCustomFields as $custom_field) {
         if (isset($this->_customFieldsMap[$custom_field])) {
             $custom_field_id = $this->_customFieldsMap[$custom_field];
             $create_fields[$custom_field_id] = $this->getIssueCustomField($issue, $custom_field_id);
         }
     }
     foreach ($component_ids as $component_id) {
         $create_fields['components'][] = array('id' => (string) $component_id);
     }
     $create_issue_result = $this->jiraApi->createIssue($project_key, $issue->get('summary'), $this->getChangelogEntryIssueTypeId(), $create_fields);
     $raw_create_issue_result = $create_issue_result->getResult();
     if (array_key_exists('errors', $raw_create_issue_result)) {
         throw new \RuntimeException(sprintf('Failed to create linked issue for "%s" issue. Errors: ' . PHP_EOL . '%s', $issue->getKey(), print_r($raw_create_issue_result['errors'], true)));
     }
     if ($link_direction === self::LINK_DIRECTION_INWARD) {
         $issue_link_result = $this->jiraApi->api(JiraApi::REQUEST_POST, '/rest/api/2/issueLink', array('type' => array('name' => $link_name), 'inwardIssue' => array('key' => $raw_create_issue_result['key']), 'outwardIssue' => array('key' => $issue->getKey())));
     } elseif ($link_direction === self::LINK_DIRECTION_OUTWARD) {
         $issue_link_result = $this->jiraApi->api(JiraApi::REQUEST_POST, '/rest/api/2/issueLink', array('type' => array('name' => $link_name), 'inwardIssue' => array('key' => $issue->getKey()), 'outwardIssue' => array('key' => $raw_create_issue_result['key'])));
     } else {
         throw new \InvalidArgumentException('The "' . $link_direction . '" link direction isn\'t valid.');
     }
     return $raw_create_issue_result['key'];
 }