1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* JiraHelper |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Fr3nch13\Jira\View\Helper; |
9
|
|
|
|
10
|
|
|
use Cake\View\Helper; |
11
|
|
|
use Cake\View\View; |
12
|
|
|
use Fr3nch13\Jira\Lib\JiraProject; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Jira Helper |
16
|
|
|
* |
17
|
|
|
* Helper to write out stuff about your jira project. |
18
|
|
|
* |
19
|
|
|
* @property \Cake\View\Helper\UrlHelper $Url |
20
|
|
|
* @property \Cake\View\Helper\HtmlHelper $Html |
21
|
|
|
*/ |
22
|
|
|
class JiraHelper extends Helper |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* List of loaded helpers. |
26
|
|
|
* |
27
|
|
|
* @var array<string> |
28
|
|
|
*/ |
29
|
|
|
public $helpers = ['Url', 'Html']; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Contains the loaded Jira Project object. |
33
|
|
|
* |
34
|
|
|
* @var \Fr3nch13\Jira\Lib\JiraProject |
35
|
|
|
*/ |
36
|
|
|
protected $JiraProject; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Initialize the helper |
40
|
|
|
* |
41
|
|
|
* @param \Cake\View\View $View The view object |
42
|
|
|
* @param array<string, mixed> $config Helper config settings |
43
|
|
|
* @return void |
44
|
|
|
*/ |
45
|
7 |
|
public function __construct(View $View, array $config = []) |
46
|
|
|
{ |
47
|
7 |
|
parent::__construct($View, $config); |
48
|
|
|
|
49
|
7 |
|
$this->JiraProject = new JiraProject(); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Get the information about the Jira Project |
54
|
|
|
* |
55
|
|
|
* @return \JiraRestApi\Project\Project Object containing the information about your project. |
56
|
|
|
* @throws \Fr3nch13\Jira\Exception\MissingProjectException If the project can't be found. |
57
|
|
|
*/ |
58
|
1 |
|
public function getInfo() |
59
|
|
|
{ |
60
|
1 |
|
$info = $this->JiraProject->getInfo(); |
61
|
|
|
|
62
|
1 |
|
return $info; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Gets a list of all versions within your project. |
67
|
|
|
* |
68
|
|
|
* @return array<\JiraRestApi\Issue\Version> A list of version objects. |
69
|
|
|
*/ |
70
|
1 |
|
public function getVersions(): array |
71
|
|
|
{ |
72
|
1 |
|
return $this->JiraProject->getVersions(); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Gets a list of all issues within your project. |
77
|
|
|
* |
78
|
|
|
* @return \JiraRestApi\Issue\IssueSearchResult|\JiraRestApi\Issue\IssueSearchResultV3 A list of issue objects. |
79
|
|
|
*/ |
80
|
1 |
|
public function getIssues(): ?\JiraRestApi\Issue\IssueSearchResult |
81
|
|
|
{ |
82
|
1 |
|
return $this->JiraProject->getIssues(); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Gets a list of all open issues within your project. |
87
|
|
|
* |
88
|
|
|
* @return \JiraRestApi\Issue\IssueSearchResult|\JiraRestApi\Issue\IssueSearchResultV3 A list of issue objects. |
89
|
|
|
*/ |
90
|
1 |
|
public function getOpenIssues(): ?\JiraRestApi\Issue\IssueSearchResult |
91
|
|
|
{ |
92
|
1 |
|
return $this->JiraProject->getOpenIssues(); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Gets info on a particular issue within your project. |
97
|
|
|
* |
98
|
|
|
* @param int $id The issue id. The integer part without the project key. |
99
|
|
|
* @return \JiraRestApi\Issue\Issue|\JiraRestApi\Issue\IssueV3 the object that has the info of that issue. |
100
|
|
|
* @throws \Fr3nch13\Jira\Exception\MissingIssueException If the project's issue can't be found. |
101
|
|
|
*/ |
102
|
1 |
|
public function getIssue($id = null) |
103
|
|
|
{ |
104
|
1 |
|
return $this->JiraProject->getIssue($id); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Gets a list of all issues that are bugs within your project. |
109
|
|
|
* |
110
|
|
|
* @return \JiraRestApi\Issue\IssueSearchResult|\JiraRestApi\Issue\IssueSearchResultV3 A list of issue objects. |
111
|
|
|
*/ |
112
|
1 |
|
public function getBugs(): ?\JiraRestApi\Issue\IssueSearchResult |
113
|
|
|
{ |
114
|
1 |
|
return $this->JiraProject->getBugs(); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Gets a list of all open issues that are bugs within your project. |
119
|
|
|
* |
120
|
|
|
* @return \JiraRestApi\Issue\IssueSearchResult|\JiraRestApi\Issue\IssueSearchResultV3 A list of issue objects. |
121
|
|
|
*/ |
122
|
1 |
|
public function getOpenBugs(): ?\JiraRestApi\Issue\IssueSearchResult |
123
|
|
|
{ |
124
|
1 |
|
return $this->JiraProject->getOpenBugs(); |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|