1 | <?php |
||
20 | class TaskEventBuilder extends BaseEventBuilder |
||
21 | { |
||
22 | /** |
||
23 | * TaskId. |
||
24 | * |
||
25 | * @var int |
||
26 | */ |
||
27 | protected $taskId = 0; |
||
28 | |||
29 | /** |
||
30 | * Task. |
||
31 | * |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $task = []; |
||
35 | |||
36 | /** |
||
37 | * Extra values. |
||
38 | * |
||
39 | * @var array |
||
40 | */ |
||
41 | protected $values = []; |
||
42 | |||
43 | /** |
||
44 | * Changed values. |
||
45 | * |
||
46 | * @var array |
||
47 | */ |
||
48 | protected $changes = []; |
||
49 | |||
50 | /** |
||
51 | * Set TaskId. |
||
52 | * |
||
53 | * @param int $taskId |
||
54 | * |
||
55 | * @return $this |
||
56 | */ |
||
57 | public function withTaskId($taskId) |
||
63 | |||
64 | /** |
||
65 | * Set task. |
||
66 | * |
||
67 | * @param array $task |
||
68 | * |
||
69 | * @return $this |
||
70 | */ |
||
71 | public function withTask(array $task) |
||
77 | |||
78 | /** |
||
79 | * Set values. |
||
80 | * |
||
81 | * @param array $values |
||
82 | * |
||
83 | * @return $this |
||
84 | */ |
||
85 | public function withValues(array $values) |
||
91 | |||
92 | /** |
||
93 | * Set changes. |
||
94 | * |
||
95 | * @param array $changes |
||
96 | * |
||
97 | * @return $this |
||
98 | */ |
||
99 | public function withChanges(array $changes) |
||
105 | |||
106 | /** |
||
107 | * Build event data. |
||
108 | * |
||
109 | * @return TaskEvent|null |
||
110 | */ |
||
111 | public function buildEvent() |
||
134 | |||
135 | /** |
||
136 | * Get event title with author. |
||
137 | * |
||
138 | * @param string $author |
||
139 | * @param string $eventName |
||
140 | * @param array $eventData |
||
141 | * |
||
142 | * @return string |
||
143 | */ |
||
144 | public function buildTitleWithAuthor($author, $eventName, array $eventData) |
||
145 | { |
||
146 | switch ($eventName) { |
||
147 | case TaskModel::EVENT_ASSIGNEE_CHANGE: |
||
148 | $assignee = $eventData['task']['assignee_name'] ?: $eventData['task']['assignee_username']; |
||
149 | |||
150 | if (!empty($assignee)) { |
||
151 | return l('%s changed the assignee of the task #%d to %s', $author, $eventData['task']['id'], $assignee); |
||
152 | } |
||
153 | |||
154 | return l('%s removed the assignee of the task %s', $author, l('#%d', $eventData['task']['id'])); |
||
155 | case TaskModel::EVENT_UPDATE: |
||
156 | return l('%s updated the task #%d', $author, $eventData['task']['id']); |
||
157 | case TaskModel::EVENT_CREATE: |
||
158 | return l('%s created the task #%d', $author, $eventData['task']['id']); |
||
159 | case TaskModel::EVENT_CLOSE: |
||
160 | return l('%s closed the task #%d', $author, $eventData['task']['id']); |
||
161 | case TaskModel::EVENT_OPEN: |
||
162 | return l('%s opened the task #%d', $author, $eventData['task']['id']); |
||
163 | case TaskModel::EVENT_MOVE_COLUMN: |
||
164 | return l( |
||
165 | '%s moved the task #%d to the column "%s"', |
||
166 | $author, |
||
167 | $eventData['task']['id'], |
||
168 | $eventData['task']['column_title'] |
||
169 | ); |
||
170 | case TaskModel::EVENT_MOVE_POSITION: |
||
171 | return l( |
||
172 | '%s moved the task #%d to the position %d in the column "%s"', |
||
173 | $author, |
||
174 | $eventData['task']['id'], |
||
175 | $eventData['task']['position'], |
||
176 | $eventData['task']['column_title'] |
||
177 | ); |
||
178 | case TaskModel::EVENT_MOVE_SWIMLANE: |
||
179 | if ($eventData['task']['swimlane_id'] == 0) { |
||
180 | return l('%s moved the task #%d to the first swimlane', $author, $eventData['task']['id']); |
||
181 | } |
||
182 | |||
183 | return l( |
||
184 | '%s moved the task #%d to the swimlane "%s"', |
||
185 | $author, |
||
186 | $eventData['task']['id'], |
||
187 | $eventData['task']['swimlane_name'] |
||
188 | ); |
||
189 | |||
190 | case TaskModel::EVENT_USER_MENTION: |
||
191 | return l('%s mentioned you in the task #%d', $author, $eventData['task']['id']); |
||
192 | default: |
||
193 | return ''; |
||
194 | } |
||
195 | } |
||
196 | |||
197 | /** |
||
198 | * Get event title without author. |
||
199 | * |
||
200 | * @param string $eventName |
||
201 | * @param array $eventData |
||
202 | * |
||
203 | * @return string |
||
204 | */ |
||
205 | public function buildTitleWithoutAuthor($eventName, array $eventData) |
||
234 | } |
||
235 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.