1 | <?php |
||
32 | class ReportsTable extends Table { |
||
33 | |||
34 | /** |
||
35 | * @var array |
||
36 | * @link http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#hasmany |
||
37 | * @see Cake::Model::$hasMany |
||
38 | */ |
||
39 | public $hasMany = array( |
||
40 | 'Incidents' => array( |
||
41 | 'dependant' => true |
||
42 | ) |
||
43 | ); |
||
44 | |||
45 | /** |
||
46 | * @var Array |
||
47 | * @link http://book.cakephp.org/2.0/en/models/model-attributes.html#validate |
||
48 | * @link http://book.cakephp.org/2.0/en/models/data-validation.html |
||
49 | * @see Model::$validate |
||
50 | */ |
||
51 | public $validate = array( |
||
52 | 'error_message' => array( |
||
53 | 'rule' => 'notEmpty', |
||
54 | 'required' => true |
||
55 | ) |
||
56 | ); |
||
57 | |||
58 | /** |
||
59 | * List of valid finder method options, supplied as the first parameter to find(). |
||
60 | * |
||
61 | * @var array |
||
62 | * @see Model::$findMethods |
||
63 | */ |
||
64 | public $findMethods = array( |
||
65 | 'allDataTable' => true, |
||
66 | 'arrayList' => true, |
||
67 | ); |
||
68 | |||
69 | /** |
||
70 | * List of valid finder method options, supplied as the first parameter to find(). |
||
71 | * |
||
72 | * @var array |
||
73 | */ |
||
74 | public $status = array( |
||
75 | 'new' => 'New', |
||
76 | 'fixed' => 'Fixed', |
||
77 | 'wontfix' => "Won't Fix", |
||
78 | 'open' => "Open", |
||
79 | 'pending' => "Pending", |
||
80 | 'resolved' => "Resolved", |
||
81 | 'invalid' => "Invalid", |
||
82 | 'duplicate' => "Duplicate", |
||
83 | 'works-for-me' => "Works for me", |
||
84 | 'out-of-date' => "Out of Date" |
||
85 | ); |
||
86 | |||
87 | 1 | public function initialize(array $config) |
|
93 | /** |
||
94 | * Retrieves the incident records that are related to the current report |
||
95 | * |
||
96 | * @return Array the list of incidents ordered by creation date desc |
||
97 | */ |
||
98 | 3 | public function getIncidents() { |
|
106 | |||
107 | /** |
||
108 | * Retrieves the report records that are related to the current report |
||
109 | * |
||
110 | * @return Array the list of related reports |
||
111 | */ |
||
112 | 1 | public function getRelatedReports() { |
|
117 | |||
118 | /** |
||
119 | * Retrieves the incident records that are related to the current report that |
||
120 | * also have a description |
||
121 | * |
||
122 | * @return Array the list of incidents ordered by description lenght desc |
||
123 | */ |
||
124 | 2 | public function getIncidentsWithDescription() { |
|
135 | |||
136 | /** |
||
137 | * Retrieves the incident records that are related to the current report that |
||
138 | * that have a different stacktrace |
||
139 | * |
||
140 | * @return Array the list of incidents |
||
141 | */ |
||
142 | 2 | public function getIncidentsWithDifferentStacktrace() { |
|
150 | |||
151 | /** |
||
152 | * Removes a report from a group of related reports |
||
153 | * |
||
154 | * @return void |
||
155 | */ |
||
156 | public function removeFromRelatedGroup($report) { |
||
174 | |||
175 | /** |
||
176 | * Adds a report to a group of related reports |
||
177 | * |
||
178 | * @return void |
||
179 | */ |
||
180 | public function addToRelatedGroup($report, $related_to) { |
||
190 | |||
191 | /** |
||
192 | * Returns the full url to the current report |
||
193 | * |
||
194 | * @return String url |
||
195 | */ |
||
196 | 1 | public function getUrl() { |
|
200 | |||
201 | /** |
||
202 | * groups related incidents by distinct values of a field. It may also provide |
||
203 | * the number of groups, whether to only include incidents that are related |
||
204 | * to the current report and also to only limit the search to incidents |
||
205 | * submited after a certain date |
||
206 | * |
||
207 | * @param String $fieldName the name of the field to group by |
||
208 | * @param Integer $limit the max number of groups to return |
||
209 | * @param Boolean $count whether to return the number of distinct groups |
||
210 | * @param Boolean $related whether to limit the search to only related incidents |
||
211 | * @param Date $timeLimit the date at which to start the search |
||
212 | * @return Array the groups with the count of each group and possibly the number |
||
213 | * of groups. Ex: array('Apache' => 2) or array(array('Apache' => 2), 1) |
||
214 | */ |
||
215 | 2 | public function getRelatedByField($fieldName, $limit = 10, $count = false, |
|
251 | |||
252 | /** |
||
253 | * returns an array of conditions that would return all related incidents to the |
||
254 | * current report |
||
255 | * |
||
256 | * @return Array the related incidents conditions |
||
257 | */ |
||
258 | 6 | protected function _relatedIncidentsConditions() { |
|
267 | |||
268 | /** |
||
269 | * returns an array of conditions that would return all related reports to the |
||
270 | * current report |
||
271 | * |
||
272 | * @return Array the related reports conditions |
||
273 | */ |
||
274 | 1 | protected function _relatedReportsConditions() { |
|
287 | } |
||
288 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: