使用Redmine的PHP API时,如何判断需求是否为原子需求_极客玩家大白

使用redmine的PHP接口时,怎样才能判断需求是否为原子需求呢,下面给出具体的做法:

1
2
3
4
5
6
7
8
9
10
11
12
13
    /**
     * 判断是否为原子需求, 即是否依然含有子需求
     * @param int $id 需求Id
     * @return int
     */
    public function hasChildIssue($id)
    {
        $res = $this->client->api('issue')->show($id, array('include' => 'children'));
        if (!empty($res) && isset($res['issue']['children'])) {
            return true;
        }
        return false;
    }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
    set_time_limit(0);
    $startTime = microtime(true);

    //检查API KEY是否配置
    $configService = $this->serviceInstance('config', 'work');
    $config = $configService->getConstApiKey();
    if (empty($config)) {
        throw new \Exception('固定API KEY未配置');
    }
    $constApiKey = $config['value'];
    $redmine = new RedmineLib($constApiKey);

    $issueId=17252;
    $temp = $redmine->client->get('/issues/'.urlencode($issueId).'.json?'.http_build_query(array ('include' => 'children')));

    $temp = $redmine->client->api('issue')->show(17252, array ('include' => 'children'));
    
    var_dump($temp['issue']['children']); exit; // 如果有子任务,['issue']['children']字段不存在,否则['issue']['children']字段对应一个子数组

//        $temp  = $redmine->client->issue->show(17252, array('include' => 'children'));
//        $temp  = $redmine->hasChildIssue(17330);
    var_dump($temp); exit;

相关链接: http://www.redmine.org/projects/redmine/wiki/Rest_Issues

Rest api with php - Redmine http://www.redmine.org/projects/redmine/wiki/Rest_api_with_php

版权声明

  • 本文作者:极客玩家大白
  • 本文链接:https://geekplayers.com/redmine-child-issue.html
  • 郑重声明:本文为博主原创或经授权转载的文章,欢迎转载,但转载文章之后必须在文章页面明显位置注明出处,否则保留追究法律责任的权利。如您有任何疑问或者授权方面的协商,请留言。


一个有故事的程序员

(转载本站文章请注明作者和出处 极客玩家大白

点击了解 :.NET技术人的网站

Show Disqus Comments

Post Directory