Search code examples
phpredminechildrenrequirements

How to judge an issue does not contain child issues in PHP API for Redmine?


Recently, I am working on a project using PHP API for Redmine. Now I need to record whether an issue has any child issues. I have tried to search for related information but failed, so I come here for help.


Solution

  • This is a function to fullfill your requirements, you can have a try.

    /**
     * @param int $id issueId
     * @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;
    }
    

    Reference: http://www.redmine.org/projects/redmine/wiki/Rest_Issues#Showing-an-issue