Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function __construct(array $values = array())
 {
     parent::__construct($values);
     $this['app_name'] = 'Jira-CLI';
     $this['app_version'] = '@git-version@';
     $this['working_directory_sub_folder'] = '.jira-cli';
     $this['config_defaults'] = array('jira.url' => '', 'jira.username' => '', 'jira.password' => '', 'cache.provider' => '');
     $this['cache'] = function ($c) {
         /** @var ConfigEditor $config_editor */
         $config_editor = $c['config_editor'];
         $cache_provider = $config_editor->get('cache.provider');
         $cache_factory = new CacheFactory('jira_url:' . $config_editor->get('jira.url'));
         return $cache_factory->create('chain', array('array', $cache_provider));
     };
     $this['jira_api'] = function ($c) {
         /** @var ConfigEditor $config_editor */
         $config_editor = $c['config_editor'];
         $authentication = new Basic($config_editor->get('jira.username'), $config_editor->get('jira.password'));
         $api = new JiraApi($config_editor->get('jira.url'), $authentication);
         $api->setCache($c['cache']);
         return $api;
     };
     $this['backportable_issue_cloner'] = function ($c) {
         return new BackportableIssueCloner($c['jira_api']);
     };
     $this['changelog_issue_cloner'] = function ($c) {
         return new ChangeLogIssueCloner($c['jira_api']);
     };
 }
 /**
  * Return possible values for the named argument
  *
  * @param string            $argumentName Argument name.
  * @param CompletionContext $context      Completion context.
  *
  * @return array
  */
 public function completeArgumentValues($argumentName, CompletionContext $context)
 {
     $ret = parent::completeArgumentValues($argumentName, $context);
     if ($argumentName === 'project_key' || $argumentName === 'project_keys') {
         return $this->jiraApi->getProjectKeys();
     }
     return $ret;
 }
Esempio n. 3
0
 /**
  * Returns ID of "Changelog Entry" issue type.
  *
  * @return integer
  * @throws \LogicException When "Changelog Entry" issue type wasn't found.
  */
 protected function getChangelogEntryIssueTypeId()
 {
     static $issue_type_id;
     if (!isset($issue_type_id)) {
         foreach ($this->jiraApi->getIssueTypes() as $issue_type) {
             if ($issue_type->getName() === 'Changelog Entry') {
                 $issue_type_id = $issue_type->getId();
                 break;
             }
         }
         if (!isset($issue_type_id)) {
             throw new \LogicException('The "Changelog Entry" issue type not found.');
         }
     }
     return $issue_type_id;
 }