1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PlaygroundGame\Controller\Frontend; |
4
|
|
|
|
5
|
|
|
use Zend\Form\Form; |
6
|
|
|
|
7
|
|
|
class PostVoteController extends GameController |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @var gameService |
11
|
|
|
*/ |
12
|
|
|
protected $gameService; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* --DONE-- 1. try to change the Game Id (on le redirige vers la home du jeu) |
16
|
|
|
* --DONE-- 2. try to modify questions (the form is recreated and verified in the controller) |
17
|
|
|
* --DONE-- 3. don't answer to questions (form is checked controller side) |
18
|
|
|
* 4. try to game the chrono |
19
|
|
|
* 5. try to play again |
20
|
|
|
* 6. try to change answers |
21
|
|
|
* --DONE-- 7. essaie de répondre sans être inscrit (on le redirige vers la home du jeu) |
22
|
|
|
*/ |
23
|
|
|
public function playAction() |
24
|
|
|
{ |
25
|
|
|
$redirectFb = $this->checkFbRegistration($this->user, $this->game); |
26
|
|
|
if ($redirectFb) { |
27
|
|
|
return $redirectFb; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
$entry = $this->getGameService()->play($this->game, $this->user); |
31
|
|
|
|
32
|
|
|
if (!$entry) { |
33
|
|
|
$lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user); |
34
|
|
|
if ($lastEntry === null) { |
35
|
|
|
return $this->redirect()->toUrl( |
36
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
37
|
|
|
'postvote', |
38
|
|
|
array('id' => $this->game->getIdentifier()) |
39
|
|
|
) |
40
|
|
|
); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
$lastEntryId = $lastEntry->getId(); |
44
|
|
|
$lastPost = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $lastEntryId)); |
45
|
|
|
$postId = $lastPost->getId(); |
46
|
|
|
if ($lastPost->getStatus() == 2) { |
47
|
|
|
// the user has already taken part to this game and the participation limit has been reached |
48
|
|
|
$this->flashMessenger()->addMessage( |
49
|
|
|
$this->getServiceLocator()->get('translator')->translate('You have already a Post') |
50
|
|
|
); |
51
|
|
|
|
52
|
|
|
return $this->redirect()->toUrl( |
53
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
54
|
|
|
'postvote/post', |
55
|
|
|
array( |
56
|
|
|
'id' => $this->game->getIdentifier(), |
57
|
|
|
'post' => $postId, |
58
|
|
|
) |
59
|
|
|
) |
60
|
|
|
); |
61
|
|
|
} else { |
62
|
|
|
$this->flashMessenger()->addMessage( |
63
|
|
|
$this->getServiceLocator()->get('translator')->translate('Your Post is waiting for validation') |
64
|
|
|
); |
65
|
|
|
|
66
|
|
|
return $this->redirect()->toUrl( |
67
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
68
|
|
|
'postvote/post', |
69
|
|
|
array( |
70
|
|
|
'id' => $this->game->getIdentifier(), |
71
|
|
|
'post' => $postId, |
72
|
|
|
|
73
|
|
|
) |
74
|
|
|
) |
75
|
|
|
); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
if (! $this->game->getForm()) { |
80
|
|
|
return $this->redirect()->toUrl( |
81
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
82
|
|
|
'postvote', |
83
|
|
|
array('id' => $this->game->getIdentifier()) |
84
|
|
|
) |
85
|
|
|
); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
$form = $this->getGameService()->createFormFromJson($this->game->getForm()->getForm(), 'postvoteForm'); |
89
|
|
|
|
90
|
|
|
// Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu. |
91
|
|
|
$post = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $entry, 'status' => 0)); |
92
|
|
|
if ($post) { |
93
|
|
|
foreach ($post->getPostElements() as $element) { |
94
|
|
|
try { |
95
|
|
|
$form->get($element->getName())->setValue($element->getValue()); |
96
|
|
|
|
97
|
|
|
$elementType = $form->get($element->getName())->getAttribute('type'); |
98
|
|
|
if ($elementType == 'file' && $element->getValue() != '') { |
99
|
|
|
$filter = $form->getInputFilter(); |
100
|
|
|
$elementInput = $filter->get($element->getName()); |
101
|
|
|
$elementInput->setRequired(false); |
102
|
|
|
$form->get($element->getName())->setAttribute('required', false); |
103
|
|
|
} |
104
|
|
|
} catch (\Zend\Form\Exception\InvalidElementException $e) { |
|
|
|
|
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
$viewModel = $this->buildView($this->game); |
110
|
|
|
|
111
|
|
|
if ($this->getRequest()->isPost()) { |
|
|
|
|
112
|
|
|
// POST Request: Process form |
113
|
|
|
$data = array_merge_recursive( |
114
|
|
|
$this->getRequest()->getPost()->toArray(), |
|
|
|
|
115
|
|
|
$this->getRequest()->getFiles()->toArray() |
|
|
|
|
116
|
|
|
); |
117
|
|
|
|
118
|
|
|
$form->setData($data); |
119
|
|
|
|
120
|
|
|
if ($form->isValid()) { |
121
|
|
|
$data = $form->getData(); |
122
|
|
|
$post = $this->getGameService()->createPost($data, $this->game, $this->user, $form); |
123
|
|
|
|
124
|
|
View Code Duplication |
if ($post && !empty($this->game->nextStep('play'))) { |
|
|
|
|
125
|
|
|
// determine the route where the user should go |
126
|
|
|
$redirectUrl = $this->frontendUrl()->fromRoute( |
|
|
|
|
127
|
|
|
'postvote/'.$this->game->nextStep('play'), |
128
|
|
|
array('id' => $this->game->getIdentifier()) |
129
|
|
|
); |
130
|
|
|
|
131
|
|
|
return $this->redirect()->toUrl($redirectUrl); |
132
|
|
|
} |
133
|
|
|
} else { |
134
|
|
|
$messages = $form->getMessages(); |
135
|
|
|
$viewModel = $this->buildView($this->game); |
136
|
|
|
$viewModel->setVariables(array( |
|
|
|
|
137
|
|
|
'success' => false, |
138
|
|
|
'message' => implode(',', $messages['title']), |
139
|
|
|
)); |
140
|
|
|
} |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
$viewModel->setVariables(array( |
144
|
|
|
'playerData' => $entry->getPlayerData(), |
145
|
|
|
'form' => $form, |
146
|
|
|
'post' => $post, |
147
|
|
|
)); |
148
|
|
|
|
149
|
|
|
return $viewModel; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
public function previewAction() |
153
|
|
|
{ |
154
|
|
|
$entry = $this->getGameService()->findLastActiveEntry($this->game, $this->user); |
155
|
|
|
|
156
|
|
View Code Duplication |
if (!$entry) { |
|
|
|
|
157
|
|
|
// the user has already taken part of this game and the participation limit has been reached |
158
|
|
|
return $this->redirect()->toUrl( |
159
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
160
|
|
|
'postvote/'.$this->game->nextStep('preview'), |
161
|
|
|
array('id' => $this->game->getIdentifier()) |
162
|
|
|
) |
163
|
|
|
); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
// Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu. |
167
|
|
|
$post = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $entry, 'status' => 0)); |
168
|
|
|
|
169
|
|
View Code Duplication |
if (! $post) { |
|
|
|
|
170
|
|
|
return $this->redirect()->toUrl( |
171
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
172
|
|
|
'postvote', |
173
|
|
|
array('id' => $this->game->getIdentifier()) |
174
|
|
|
) |
175
|
|
|
); |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
if ($this->getRequest()->isPost()) { |
|
|
|
|
179
|
|
|
$post = $this->getGameService()->confirmPost($this->game, $this->user); |
180
|
|
|
|
181
|
|
|
if ($post) { |
182
|
|
|
if (!($step = $this->game->nextStep('play'))) { |
183
|
|
|
$step = 'result'; |
184
|
|
|
} |
185
|
|
|
$redirectUrl = $this->frontendUrl()->fromRoute( |
|
|
|
|
186
|
|
|
'postvote/'.$step, |
187
|
|
|
array('id' => $this->game->getIdentifier()) |
188
|
|
|
); |
189
|
|
|
|
190
|
|
|
return $this->redirect()->toUrl($redirectUrl); |
191
|
|
|
} |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
$viewModel = $this->buildView($this->game); |
195
|
|
|
$viewModel->setVariables(array('post' => $post)); |
|
|
|
|
196
|
|
|
|
197
|
|
|
return $viewModel; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* View the Post page |
202
|
|
|
* @return multitype:|\Zend\Http\Response|\Zend\View\Model\ViewModel |
|
|
|
|
203
|
|
|
*/ |
204
|
|
|
public function postAction() |
205
|
|
|
{ |
206
|
|
|
$postId = $this->getEvent()->getRouteMatch()->getParam('post'); |
207
|
|
|
$voted = false; |
208
|
|
|
$statusMail = false; |
209
|
|
|
$mailService = $this->getServiceLocator()->get('playgroundgame_message'); |
210
|
|
|
$to = ''; |
211
|
|
|
$skinUrl = $this->getGameService()->getServiceManager()->get('ViewRenderer')->url( |
212
|
|
|
'frontend', |
213
|
|
|
array(), |
214
|
|
|
array('force_canonical' => true) |
215
|
|
|
); |
216
|
|
|
$config = $this->getGameService()->getServiceManager()->get('config'); |
217
|
|
|
if (isset($config['moderation']['email'])) { |
218
|
|
|
$to = $config['moderation']['email']; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
if (! $postId) { |
222
|
|
|
return $this->notFoundAction(); |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
// Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu. |
226
|
|
|
$post = $this->getGameService()->getPostVotePostMapper()->findById($postId); |
227
|
|
|
|
228
|
|
View Code Duplication |
if (! $post || $post->getStatus() === 9) { |
|
|
|
|
229
|
|
|
return $this->redirect()->toUrl( |
230
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
231
|
|
|
'postvote', |
232
|
|
|
array('id' => $this->game->getIdentifier()) |
233
|
|
|
) |
234
|
|
|
); |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
$formModeration = new Form(); |
238
|
|
|
$formModeration->setAttribute('method', 'post'); |
239
|
|
|
|
240
|
|
|
$formModeration->add(array( |
241
|
|
|
'name' => 'moderation', |
242
|
|
|
'attributes' => array( |
243
|
|
|
'type' => 'hidden', |
244
|
|
|
'value' => '1' |
245
|
|
|
), |
246
|
|
|
)); |
247
|
|
|
|
248
|
|
|
$form = new \PlaygroundGame\Form\Frontend\PostVoteVote( |
249
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
250
|
|
|
'postvote/post/captcha', |
251
|
|
|
array( |
252
|
|
|
'id' => $this->game->getIdentifier(), |
253
|
|
|
'post' => $postId, |
254
|
|
|
) |
255
|
|
|
) |
256
|
|
|
); |
257
|
|
|
|
258
|
|
|
if ($this->user) { |
259
|
|
|
$form->remove('captcha'); |
260
|
|
|
if(count($this->getGameService()->getPostvoteVoteMapper()->findBy(array('user' => $this->user, 'post' =>$post))) > 0) $voted = true; |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
$alreadyVoted = ''; |
264
|
|
|
$reportId = ''; |
265
|
|
|
|
266
|
|
|
$request = $this->getRequest(); |
267
|
|
|
if ($request->isPost()) { |
268
|
|
|
$data = $request->getPost()->toArray(); |
269
|
|
|
if (isset($data['moderation'])) { |
270
|
|
|
$formModeration->setData($data); |
271
|
|
|
if ($formModeration->isValid()) { |
272
|
|
|
$from = $to; |
273
|
|
|
$subject= 'Moderation Post and Vote'; |
274
|
|
|
$result = $mailService->createHtmlMessage( |
275
|
|
|
$from, |
276
|
|
|
$to, |
277
|
|
|
$subject, |
278
|
|
|
'playground-game/email/moderation', |
279
|
|
|
array('data' => $data, 'skinUrl' => $skinUrl) |
280
|
|
|
); |
281
|
|
|
$mailService->send($result); |
282
|
|
|
if ($result) { |
283
|
|
|
$statusMail = true; |
284
|
|
|
$reportId = $data['reportid']; |
285
|
|
|
} |
286
|
|
|
} |
287
|
|
|
} else { |
288
|
|
|
$form->setData($request->getPost()); |
289
|
|
|
if ($form->isValid()) { |
290
|
|
|
if ($this->getGameService()->addVote( |
291
|
|
|
$this->user, |
292
|
|
|
$this->getRequest()->getServer('REMOTE_ADDR'), |
|
|
|
|
293
|
|
|
$post |
294
|
|
|
)) { |
295
|
|
|
$voted = true; |
296
|
|
|
} else { |
297
|
|
|
$alreadyVoted = 'Vous avez déjà voté!'; |
298
|
|
|
} |
299
|
|
|
} |
300
|
|
|
} |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
$viewModel = $this->buildView($this->game); |
304
|
|
|
$viewModel->setVariables( |
|
|
|
|
305
|
|
|
array( |
306
|
|
|
'post' => $post, |
307
|
|
|
'voted' => $voted, |
308
|
|
|
'form' => $form, |
309
|
|
|
'formModeration' => $formModeration, |
310
|
|
|
'statusMail' => $statusMail, |
311
|
|
|
'alreadyVoted' => $alreadyVoted, |
312
|
|
|
'reportId' => $reportId, |
313
|
|
|
) |
314
|
|
|
); |
315
|
|
|
|
316
|
|
|
return $viewModel; |
317
|
|
|
} |
318
|
|
|
|
319
|
|
|
/** |
320
|
|
|
* |
321
|
|
|
*/ |
322
|
|
|
public function resultAction() |
323
|
|
|
{ |
324
|
|
|
$lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user); |
325
|
|
|
if ($lastEntry == null) { |
326
|
|
|
return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('postvote', array('id' => $identifier))); |
|
|
|
|
327
|
|
|
} |
328
|
|
|
// Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu. |
329
|
|
|
$post = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $lastEntry)); |
330
|
|
|
|
331
|
|
|
if (! $post) { |
332
|
|
|
|
333
|
|
|
return $this->redirect()->toUrl( |
334
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
335
|
|
|
'postvote', |
336
|
|
|
array('id' => $this->game->getIdentifier()) |
337
|
|
|
) |
338
|
|
|
); |
339
|
|
|
} |
340
|
|
|
|
341
|
|
|
$view = $this->forward()->dispatch( |
342
|
|
|
'playgroundgame_'.$this->game->getClassType(), |
343
|
|
|
array( |
344
|
|
|
'controller' => 'playgroundgame_'.$this->game->getClassType(), |
345
|
|
|
'action' => 'share', |
346
|
|
|
'id' => $this->game->getIdentifier() |
347
|
|
|
) |
348
|
|
|
); |
349
|
|
|
|
350
|
|
|
if ($view && $view instanceof \Zend\View\Model\ViewModel) { |
351
|
|
|
$view->setVariables(array('post' => $post)); |
352
|
|
|
|
353
|
|
|
return $view; |
354
|
|
|
} elseif ($view && $view instanceof \Zend\Http\PhpEnvironment\Response) { |
355
|
|
|
return $view; |
356
|
|
|
} else { |
357
|
|
|
$form = $this->getServiceLocator()->get('playgroundgame_sharemail_form'); |
358
|
|
|
$form->setAttribute('method', 'post'); |
359
|
|
|
|
360
|
|
|
$viewModel = $this->buildView($this->game); |
361
|
|
|
|
362
|
|
|
$viewModel->setVariables(array( |
|
|
|
|
363
|
|
|
'statusMail' => null, |
364
|
|
|
'post' => $post, |
365
|
|
|
'form' => $form, |
366
|
|
|
)); |
367
|
|
|
|
368
|
|
|
return $viewModel; |
369
|
|
|
} |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
/** |
373
|
|
|
* Example of AJAX File Upload with Session Progress and partial validation. |
374
|
|
|
* It's now possible to send a base64 image in this case the call is the form : |
375
|
|
|
* this._ajax( |
376
|
|
|
* { |
377
|
|
|
* url: url.dataset.url, |
378
|
|
|
* method: 'post', |
379
|
|
|
* body: 'photo=' + image |
380
|
|
|
* }, |
381
|
|
|
* |
382
|
|
|
* @return \Zend\Stdlib\ResponseInterface |
383
|
|
|
*/ |
384
|
|
|
public function ajaxuploadAction() |
385
|
|
|
{ |
386
|
|
|
// Call this for the session lock to be released (other ajax calls can then be made) |
387
|
|
|
session_write_close(); |
388
|
|
|
|
389
|
|
|
if (! $this->game) { |
390
|
|
|
$this->getResponse()->setContent(\Zend\Json\Json::encode(array( |
391
|
|
|
'success' => 0 |
392
|
|
|
))); |
393
|
|
|
|
394
|
|
|
return $this->getResponse(); |
395
|
|
|
} |
396
|
|
|
|
397
|
|
|
$entry = $this->getGameService()->findLastActiveEntry( |
398
|
|
|
$this->game, |
399
|
|
|
$this->user |
400
|
|
|
); |
401
|
|
|
if (!$entry) { |
402
|
|
|
// the user has already taken part of this game and the participation limit has been reached |
403
|
|
|
$this->getResponse()->setContent(\Zend\Json\Json::encode(array( |
404
|
|
|
'success' => 0 |
405
|
|
|
))); |
406
|
|
|
|
407
|
|
|
return $this->getResponse(); |
408
|
|
|
} |
409
|
|
|
|
410
|
|
|
if ($this->getRequest()->isPost()) { |
|
|
|
|
411
|
|
|
$data = $this->getRequest()->getFiles()->toArray(); |
|
|
|
|
412
|
|
|
|
413
|
|
|
if (empty($data)) { |
414
|
|
|
$data = $this->getRequest()->getPost()->toArray(); |
|
|
|
|
415
|
|
|
$key = key($data); |
416
|
|
|
$uploadImage = array('name' => $key.'.png', 'error' => 0, 'base64' => $data[$key]); |
417
|
|
|
$data = array($key => $uploadImage); |
418
|
|
|
} |
419
|
|
|
$uploadFile = $this->getGameService()->uploadFileToPost( |
420
|
|
|
$data, |
421
|
|
|
$this->game, |
422
|
|
|
$this->user |
423
|
|
|
); |
424
|
|
|
} |
425
|
|
|
|
426
|
|
|
$this->getResponse()->setContent(\Zend\Json\Json::encode(array( |
427
|
|
|
'success' => true, |
428
|
|
|
'fileUrl' => $uploadFile |
|
|
|
|
429
|
|
|
))); |
430
|
|
|
|
431
|
|
|
return $this->getResponse(); |
432
|
|
|
} |
433
|
|
|
|
434
|
|
|
public function ajaxdeleteAction() |
435
|
|
|
{ |
436
|
|
|
$response = $this->getResponse(); |
437
|
|
|
|
438
|
|
|
if (! $this->game) { |
439
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
440
|
|
|
'success' => 0 |
441
|
|
|
))); |
442
|
|
|
|
443
|
|
|
return $response; |
444
|
|
|
} |
445
|
|
|
|
446
|
|
|
$entry = $this->getGameService()->findLastActiveEntry($this->game, $this->user); |
447
|
|
|
if (!$entry) { |
448
|
|
|
// the user has already taken part of this game and the participation limit has been reached |
449
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
450
|
|
|
'success' => 0 |
451
|
|
|
))); |
452
|
|
|
|
453
|
|
|
return $response; |
454
|
|
|
} |
455
|
|
|
if ($request->isPost()) { |
456
|
|
|
$data = $request->getPost()->toArray(); |
|
|
|
|
457
|
|
|
$this->getGameService()->deleteFilePosted($data, $this->game, $this->user); |
458
|
|
|
} |
459
|
|
|
|
460
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
461
|
|
|
'success' => true, |
462
|
|
|
))); |
463
|
|
|
|
464
|
|
|
return $response; |
465
|
|
|
} |
466
|
|
|
|
467
|
|
|
public function ajaxrejectPostAction() |
468
|
|
|
{ |
469
|
|
|
$response = $this->getResponse(); |
470
|
|
|
$postId = $this->getEvent()->getRouteMatch()->getParam('post'); |
471
|
|
|
|
472
|
|
|
if (! $postId) { |
473
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
474
|
|
|
'success' => 0 |
475
|
|
|
))); |
476
|
|
|
|
477
|
|
|
return $response; |
478
|
|
|
} |
479
|
|
|
|
480
|
|
|
$post = $this->getGameService()->getPostVotePostMapper()->findById($postId); |
481
|
|
|
|
482
|
|
|
if (! $post || $post->getUser()->getId() !== $this->user->getId()) { |
483
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
484
|
|
|
'success' => 0 |
485
|
|
|
))); |
486
|
|
|
|
487
|
|
|
return $response; |
488
|
|
|
} |
489
|
|
|
|
490
|
|
|
if ($this->getRequest()->isPost()) { |
|
|
|
|
491
|
|
|
$postvotePostMapper = $this->getGameService()->getPostVotePostMapper(); |
492
|
|
|
// Post is rejected by User |
493
|
|
|
$post->setStatus(8); |
494
|
|
|
$postvotePostMapper->update($post); |
495
|
|
|
} |
496
|
|
|
|
497
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
498
|
|
|
'success' => true, |
499
|
|
|
))); |
500
|
|
|
|
501
|
|
|
return $response; |
502
|
|
|
} |
503
|
|
|
|
504
|
|
|
public function listAction() |
505
|
|
|
{ |
506
|
|
|
$filter = $this->getEvent()->getRouteMatch()->getParam('filter'); |
507
|
|
|
$search = $this->params()->fromQuery('name'); |
508
|
|
|
$postId = $this->params()->fromQuery('id'); |
509
|
|
|
$statusMail = false; |
510
|
|
|
$mailService = $this->getServiceLocator()->get('playgroundgame_message'); |
511
|
|
|
$to = ''; |
512
|
|
|
$skinUrl = $this->getGameService()->getServiceManager()->get('ViewRenderer')->url( |
513
|
|
|
'frontend', |
514
|
|
|
array(), |
515
|
|
|
array('force_canonical' => true) |
516
|
|
|
); |
517
|
|
|
$config = $this->getGameService()->getServiceManager()->get('config'); |
518
|
|
|
if (isset($config['moderation']['email'])) { |
519
|
|
|
$to = $config['moderation']['email']; |
520
|
|
|
} |
521
|
|
|
|
522
|
|
|
$request = $this->getRequest(); |
523
|
|
|
|
524
|
|
|
// Je recherche les posts validés associés à ce jeu |
525
|
|
|
$posts = $this->getGameService()->findArrayOfValidatedPosts($this->game, $this->user, $filter, $search); |
526
|
|
|
|
527
|
|
|
if (is_array($posts)) { |
528
|
|
|
$paginator = new \Zend\Paginator\Paginator(new \Zend\Paginator\Adapter\ArrayAdapter($posts)); |
529
|
|
|
$paginator->setItemCountPerPage($this->game->getPostDisplayNumber()); |
530
|
|
|
$paginator->setCurrentPageNumber($this->getEvent()->getRouteMatch()->getParam('p')); |
531
|
|
|
} else { |
532
|
|
|
$paginator = $posts; |
533
|
|
|
} |
534
|
|
|
|
535
|
|
|
$form = new Form(); |
536
|
|
|
$form->setAttribute('method', 'post'); |
537
|
|
|
|
538
|
|
|
$form->add(array( |
539
|
|
|
'name' => 'moderation', |
540
|
|
|
'attributes' => array( |
541
|
|
|
'type' => 'hidden', |
542
|
|
|
'value' => '1' |
543
|
|
|
), |
544
|
|
|
)); |
545
|
|
|
|
546
|
|
|
$reportId =''; |
547
|
|
|
|
548
|
|
|
if ($request->isPost()) { |
549
|
|
|
$data = $request->getPost()->toArray(); |
550
|
|
|
|
551
|
|
|
if (isset($data['moderation'])) { |
552
|
|
|
$from = $to; |
553
|
|
|
$subject= 'Moderation Post and Vote'; |
554
|
|
|
$result = $mailService->createHtmlMessage( |
555
|
|
|
$from, |
556
|
|
|
$to, |
557
|
|
|
$subject, |
558
|
|
|
'playground-game/email/moderation', |
559
|
|
|
array('data' => $data, 'skinUrl' => $skinUrl) |
560
|
|
|
); |
561
|
|
|
$mailService->send($result); |
562
|
|
|
if ($result) { |
563
|
|
|
$statusMail = true; |
564
|
|
|
$reportId = $data['reportid']; |
565
|
|
|
} |
566
|
|
|
} |
567
|
|
|
} |
568
|
|
|
|
569
|
|
|
$viewModel = $this->buildView($this->game); |
570
|
|
|
|
571
|
|
|
if ($postId) { |
572
|
|
|
$postTarget = $this->getGameService()->getPostVotePostMapper()->findById($postId); |
573
|
|
|
if ($postTarget) { |
574
|
|
View Code Duplication |
foreach ($postTarget->getPostElements() as $element) { |
|
|
|
|
575
|
|
|
$fbShareImage = $this->frontendUrl()->fromRoute( |
|
|
|
|
576
|
|
|
'', |
577
|
|
|
array(), |
578
|
|
|
array('force_canonical' => true), |
579
|
|
|
false |
580
|
|
|
) . $element->getValue(); |
581
|
|
|
break; |
582
|
|
|
} |
583
|
|
|
|
584
|
|
|
$secretKey = strtoupper(substr(sha1(uniqid('pg_', true).'####'.time()), 0, 15)); |
585
|
|
|
|
586
|
|
|
// Without bit.ly shortener |
587
|
|
|
$socialLinkUrl = $this->frontendUrl()->fromRoute( |
|
|
|
|
588
|
|
|
'postvote/list', |
589
|
|
|
array( |
590
|
|
|
'id' => $this->game->getIdentifier(), |
591
|
|
|
'filter' => 'date'), |
592
|
|
|
array('force_canonical' => true) |
593
|
|
|
).'?id='.$postTarget->getId().'&key='.$secretKey; |
594
|
|
|
// With core shortener helper |
595
|
|
|
$socialLinkUrl = $this->shortenUrl()->shortenUrl($socialLinkUrl); |
|
|
|
|
596
|
|
|
|
597
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('og:image', $fbShareImage); |
|
|
|
|
598
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:card', "photo"); |
599
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:site', "@alfie_selfie"); |
600
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:title', $this->game->getTwShareMessage()); |
601
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:description', ""); |
602
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:image', $fbShareImage); |
603
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:url', $socialLinkUrl); |
604
|
|
|
} |
605
|
|
|
} |
606
|
|
|
|
607
|
|
|
$viewModel->setVariables(array( |
|
|
|
|
608
|
|
|
'posts' => $paginator, |
609
|
|
|
'form' => $form, |
610
|
|
|
'statusMail' => $statusMail, |
611
|
|
|
'reportId' => $reportId, |
612
|
|
|
'filter' => $filter, |
613
|
|
|
'search' => $search, |
614
|
|
|
)); |
615
|
|
|
|
616
|
|
|
return $viewModel; |
617
|
|
|
} |
618
|
|
|
|
619
|
|
|
public function ajaxVoteAction() |
620
|
|
|
{ |
621
|
|
|
// Call this for the session lock to be released (other ajax calls can then be made) |
622
|
|
|
session_write_close(); |
623
|
|
|
$postId = $this->getEvent()->getRouteMatch()->getParam('post'); |
624
|
|
|
$request = $this->getRequest(); |
625
|
|
|
$response = $this->getResponse(); |
626
|
|
|
|
627
|
|
|
if (! $this->game) { |
628
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
629
|
|
|
'success' => 0 |
630
|
|
|
))); |
631
|
|
|
|
632
|
|
|
return $response; |
633
|
|
|
} |
634
|
|
|
|
635
|
|
View Code Duplication |
if (!$this->zfcUserAuthentication()->hasIdentity()) { |
|
|
|
|
636
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
637
|
|
|
'success' => 0 |
638
|
|
|
))); |
639
|
|
|
} else { |
640
|
|
|
if ($request->isPost()) { |
641
|
|
|
$post = $this->getGameService()->getPostvotePostMapper()->findById($postId); |
642
|
|
|
if ($this->getGameService()->addVote( |
643
|
|
|
$this->user, |
644
|
|
|
$this->getRequest()->getServer('REMOTE_ADDR'), |
|
|
|
|
645
|
|
|
$post |
646
|
|
|
)) { |
647
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
648
|
|
|
'success' => 1 |
649
|
|
|
))); |
650
|
|
|
} else { |
651
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
652
|
|
|
'success' => 0 |
653
|
|
|
))); |
654
|
|
|
} |
655
|
|
|
} |
656
|
|
|
} |
657
|
|
|
|
658
|
|
|
return $response; |
659
|
|
|
} |
660
|
|
|
|
661
|
|
|
public function commentsAction() |
662
|
|
|
{ |
663
|
|
|
|
664
|
|
|
$postId = $this->getEvent()->getRouteMatch()->getParam('post'); |
665
|
|
|
if($postId){ |
666
|
|
|
$post = $this->getGameService()->getPostvotePostMapper()->findById($postId); |
667
|
|
|
$comments = $post->getComments(); |
668
|
|
|
} else { |
669
|
|
|
$comments = $this->getGameService()->getCommentsForPostvote($this->game); |
670
|
|
|
} |
671
|
|
|
|
672
|
|
|
if (is_array($comments)) { |
673
|
|
|
$paginator = new \Zend\Paginator\Paginator(new \Zend\Paginator\Adapter\ArrayAdapter($comments)); |
674
|
|
|
$paginator->setItemCountPerPage(25); |
675
|
|
|
$paginator->setCurrentPageNumber($this->getEvent()->getRouteMatch()->getParam('p')); |
676
|
|
|
} else { |
677
|
|
|
$paginator = $comments; |
678
|
|
|
} |
679
|
|
|
|
680
|
|
|
$viewModel = $this->buildView($this->game); |
681
|
|
|
$viewModel->setVariables(array('comments' => $paginator)); |
|
|
|
|
682
|
|
|
|
683
|
|
|
return $viewModel; |
684
|
|
|
} |
685
|
|
|
|
686
|
|
|
public function commentAction() |
687
|
|
|
{ |
688
|
|
|
if ($this->getRequest()->isXmlHttpRequest()) { |
|
|
|
|
689
|
|
|
// Call this for the session lock to be released (other ajax calls can then be made) |
690
|
|
|
session_write_close(); |
691
|
|
|
} |
692
|
|
|
$postId = $this->getEvent()->getRouteMatch()->getParam('post'); |
693
|
|
|
$request = $this->getRequest(); |
694
|
|
|
$response = $this->getResponse(); |
695
|
|
|
$post = $this->getGameService()->getPostvotePostMapper()->findById($postId); |
696
|
|
|
|
697
|
|
View Code Duplication |
if (!$this->zfcUserAuthentication()->hasIdentity()) { |
|
|
|
|
698
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
699
|
|
|
'success' => 0 |
700
|
|
|
))); |
701
|
|
|
} else { |
702
|
|
|
if ($request->isPost()) { |
703
|
|
|
if ($this->getGameService()->addComment( |
704
|
|
|
$this->user, |
705
|
|
|
$this->getRequest()->getServer('REMOTE_ADDR'), |
|
|
|
|
706
|
|
|
$post, |
707
|
|
|
$this->params()->fromPost('comment') |
708
|
|
|
)) { |
709
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
710
|
|
|
'success' => 1 |
711
|
|
|
))); |
712
|
|
|
} else { |
713
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
714
|
|
|
'success' => 0 |
715
|
|
|
))); |
716
|
|
|
} |
717
|
|
|
} |
718
|
|
|
} |
719
|
|
|
|
720
|
|
|
//ajax call ? |
721
|
|
|
if ($this->getRequest()->isXmlHttpRequest()) { |
|
|
|
|
722
|
|
|
|
723
|
|
|
return $response; |
724
|
|
|
} |
725
|
|
|
|
726
|
|
|
$this->flashMessenger()->addMessage( |
727
|
|
|
$this->getServiceLocator()->get('translator')->translate('Your comment has been recorded') |
728
|
|
|
); |
729
|
|
|
|
730
|
|
|
return $this->redirect()->toUrl( |
731
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
732
|
|
|
'les-idees/idee', |
733
|
|
|
array('post' => $post->getId()) |
734
|
|
|
) |
735
|
|
|
); |
736
|
|
|
} |
737
|
|
|
|
738
|
|
|
public function ajaxRemoveCommentAction() |
739
|
|
|
{ |
740
|
|
|
// Call this for the session lock to be released (other ajax calls can then be made) |
741
|
|
|
session_write_close(); |
742
|
|
|
$commentId = $this->getEvent()->getRouteMatch()->getParam('comment'); |
743
|
|
|
$request = $this->getRequest(); |
744
|
|
|
$response = $this->getResponse(); |
745
|
|
|
|
746
|
|
|
if (! $this->game) { |
747
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
748
|
|
|
'success' => 0 |
749
|
|
|
))); |
750
|
|
|
|
751
|
|
|
return $response; |
752
|
|
|
} |
753
|
|
|
|
754
|
|
View Code Duplication |
if (!$this->zfcUserAuthentication()->hasIdentity()) { |
|
|
|
|
755
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
756
|
|
|
'success' => 0 |
757
|
|
|
))); |
758
|
|
|
} else { |
759
|
|
|
if ($request->isPost()) { |
760
|
|
|
if ($this->getGameService()->removeComment( |
761
|
|
|
$this->user, |
762
|
|
|
$this->getRequest()->getServer('REMOTE_ADDR'), |
|
|
|
|
763
|
|
|
$commentId |
764
|
|
|
)) { |
765
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
766
|
|
|
'success' => 1 |
767
|
|
|
))); |
768
|
|
|
} else { |
769
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
770
|
|
|
'success' => 0 |
771
|
|
|
))); |
772
|
|
|
} |
773
|
|
|
} |
774
|
|
|
} |
775
|
|
|
|
776
|
|
|
return $response; |
777
|
|
|
} |
778
|
|
|
|
779
|
|
|
public function captchaAction() |
780
|
|
|
{ |
781
|
|
|
$response = $this->getResponse(); |
782
|
|
|
$response->getHeaders()->addHeaderLine('Content-Type', "image/png"); |
783
|
|
|
|
784
|
|
|
$id = $this->params('id', false); |
785
|
|
|
|
786
|
|
|
if ($id) { |
787
|
|
|
$image = './data/captcha/' . $id; |
788
|
|
|
|
789
|
|
|
if (file_exists($image) !== false) { |
790
|
|
|
$imagegetcontent = file_get_contents($image); |
791
|
|
|
|
792
|
|
|
$response->setStatusCode(200); |
793
|
|
|
$response->setContent($imagegetcontent); |
794
|
|
|
|
795
|
|
|
if (file_exists($image) === true) { |
796
|
|
|
unlink($image); |
797
|
|
|
} |
798
|
|
|
} |
799
|
|
|
} |
800
|
|
|
|
801
|
|
|
return $response; |
802
|
|
|
} |
803
|
|
|
|
804
|
|
|
public function sharePostAction() |
805
|
|
|
{ |
806
|
|
|
$statusMail = false; |
807
|
|
|
$message = ''; |
808
|
|
|
|
809
|
|
|
$postId = $this->getEvent()->getRouteMatch()->getParam('post'); |
810
|
|
|
$post = $this->getGameService()->getPostVotePostMapper()->findById($postId); |
811
|
|
|
|
812
|
|
|
$secretKey = strtoupper(substr(sha1(uniqid('pg_', true).'####'.time()), 0, 15)); |
813
|
|
|
$socialLinkUrl = $this->frontendUrl()->fromRoute( |
|
|
|
|
814
|
|
|
'postvote/post', |
815
|
|
|
array( |
816
|
|
|
'id' => $this->game->getIdentifier(), |
817
|
|
|
'post' => $post->getId(), |
818
|
|
|
), |
819
|
|
|
array('force_canonical' => true) |
820
|
|
|
).'?key='.$secretKey; |
821
|
|
|
// With core shortener helper |
822
|
|
|
$socialLinkUrl = $this->shortenUrl()->shortenUrl($socialLinkUrl); |
|
|
|
|
823
|
|
|
|
824
|
|
|
$form = $this->getServiceLocator()->get('playgroundgame_sharemail_form'); |
825
|
|
|
$form->setAttribute('method', 'post'); |
826
|
|
|
|
827
|
|
View Code Duplication |
if ($this->getRequest()->isPost()) { |
|
|
|
|
828
|
|
|
$data = $this->getRequest()->getPost()->toArray(); |
|
|
|
|
829
|
|
|
$form->setData($data); |
830
|
|
|
if ($form->isValid()) { |
831
|
|
|
$data['post'] = $post; |
832
|
|
|
$result = $this->getGameService()->sendShareMail($data, $this->game, $this->user, null, 'share-post'); |
833
|
|
|
if ($result) { |
834
|
|
|
$statusMail = true; |
835
|
|
|
$this->getGameService()->addShare($post); |
836
|
|
|
} |
837
|
|
|
} else { |
838
|
|
|
foreach($form->getMessages() as $el=> $errors){ |
839
|
|
|
foreach($errors as $key => $message){ |
840
|
|
|
$message = $this->getServiceLocator()->get('translator')->translate($message); |
841
|
|
|
} |
842
|
|
|
|
843
|
|
|
} |
844
|
|
|
} |
845
|
|
|
} |
846
|
|
|
|
847
|
|
|
$viewModel = $this->buildView($this->game); |
848
|
|
|
|
849
|
|
|
$viewModel->setVariables(array( |
|
|
|
|
850
|
|
|
'statusMail' => $statusMail, |
851
|
|
|
'message' => $message, |
852
|
|
|
'form' => $form, |
853
|
|
|
'socialLinkUrl' => $socialLinkUrl, |
854
|
|
|
'post' => $post |
855
|
|
|
)); |
856
|
|
|
|
857
|
|
|
return $viewModel; |
858
|
|
|
} |
859
|
|
|
|
860
|
|
|
public function shareCommentAction() |
861
|
|
|
{ |
862
|
|
|
$statusMail = false; |
863
|
|
|
$message = ''; |
864
|
|
|
|
865
|
|
|
$commentId = $this->getEvent()->getRouteMatch()->getParam('comment'); |
866
|
|
|
$comment = $this->getGameService()->getPostVoteCommentMapper()->findById($commentId); |
867
|
|
|
|
868
|
|
|
$form = $this->getServiceLocator()->get('playgroundgame_sharemail_form'); |
869
|
|
|
$form->setAttribute('method', 'post'); |
870
|
|
|
|
871
|
|
View Code Duplication |
if ($this->getRequest()->isPost()) { |
|
|
|
|
872
|
|
|
$data = $this->getRequest()->getPost()->toArray(); |
|
|
|
|
873
|
|
|
$form->setData($data); |
874
|
|
|
if ($form->isValid()) { |
875
|
|
|
$data['comment'] = $comment; |
876
|
|
|
$subject = $this->getGameService()->getOptions()->getShareCommentSubjectLine(); |
877
|
|
|
$result = $this->getGameService()->sendShareMail($data, $this->game, $this->user, null, 'share-comment', null, array(), $subject); |
878
|
|
|
if ($result) { |
879
|
|
|
$statusMail = true; |
880
|
|
|
} |
881
|
|
|
} else { |
882
|
|
|
foreach($form->getMessages() as $el=> $errors){ |
883
|
|
|
foreach($errors as $key => $message){ |
884
|
|
|
$message = $this->getServiceLocator()->get('translator')->translate($message); |
885
|
|
|
} |
886
|
|
|
|
887
|
|
|
} |
888
|
|
|
} |
889
|
|
|
} |
890
|
|
|
|
891
|
|
|
$viewModel = $this->buildView($this->game); |
892
|
|
|
|
893
|
|
|
$viewModel->setVariables(array( |
|
|
|
|
894
|
|
|
'statusMail' => $statusMail, |
895
|
|
|
'message' => $message, |
896
|
|
|
'form' => $form, |
897
|
|
|
'comment' => $comment |
898
|
|
|
)); |
899
|
|
|
|
900
|
|
|
return $viewModel; |
901
|
|
|
} |
902
|
|
|
|
903
|
|
|
public function shareAction() |
904
|
|
|
{ |
905
|
|
|
$statusMail = null; |
906
|
|
|
|
907
|
|
|
// Has the user finished the game ? |
908
|
|
|
$lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user); |
909
|
|
|
|
910
|
|
|
if ($lastEntry === null) { |
911
|
|
|
return $this->redirect()->toUrl( |
912
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
913
|
|
|
'postvote', |
914
|
|
|
array('id' => $this->game->getIdentifier()) |
915
|
|
|
) |
916
|
|
|
); |
917
|
|
|
} |
918
|
|
|
|
919
|
|
|
$post = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $lastEntry)); |
920
|
|
|
|
921
|
|
|
$secretKey = strtoupper(substr(sha1(uniqid('pg_', true).'####'.time()), 0, 15)); |
922
|
|
|
$socialLinkUrl = $this->frontendUrl()->fromRoute( |
|
|
|
|
923
|
|
|
'postvote/post', |
924
|
|
|
array( |
925
|
|
|
'id' => $this->game->getIdentifier(), |
926
|
|
|
'post' => $post->getId(), |
927
|
|
|
), |
928
|
|
|
array('force_canonical' => true) |
929
|
|
|
).'?key='.$secretKey; |
930
|
|
|
// With core shortener helper |
931
|
|
|
$socialLinkUrl = $this->shortenUrl()->shortenUrl($socialLinkUrl); |
|
|
|
|
932
|
|
|
|
933
|
|
|
$form = $this->getServiceLocator()->get('playgroundgame_sharemail_form'); |
934
|
|
|
$form->setAttribute('method', 'post'); |
935
|
|
|
|
936
|
|
View Code Duplication |
if ($this->getRequest()->isPost()) { |
|
|
|
|
937
|
|
|
$data = $this->getRequest()->getPost()->toArray(); |
|
|
|
|
938
|
|
|
$form->setData($data); |
939
|
|
|
if ($form->isValid()) { |
940
|
|
|
$result = $this->getGameService()->sendShareMail($data, $this->game, $this->user, $lastEntry); |
941
|
|
|
if ($result) { |
942
|
|
|
$statusMail = true; |
943
|
|
|
} |
944
|
|
|
} |
945
|
|
|
} |
946
|
|
|
|
947
|
|
|
$viewModel = $this->buildView($this->game); |
948
|
|
|
|
949
|
|
View Code Duplication |
foreach ($post->getPostElements() as $element) { |
|
|
|
|
950
|
|
|
$fbShareImage = $this->frontendUrl()->fromRoute( |
|
|
|
|
951
|
|
|
'', |
952
|
|
|
array(), |
953
|
|
|
array('force_canonical' => true), |
954
|
|
|
false |
955
|
|
|
) . $element->getValue(); |
956
|
|
|
break; |
957
|
|
|
} |
958
|
|
|
|
959
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('og:image', $fbShareImage); |
|
|
|
|
960
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:card', "photo"); |
961
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:site', "@playground"); |
962
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:title', $this->game->getTwShareMessage()); |
963
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:description', ""); |
964
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:image', $fbShareImage); |
965
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:url', $socialLinkUrl); |
966
|
|
|
|
967
|
|
|
$viewModel->setVariables(array( |
|
|
|
|
968
|
|
|
'statusMail' => $statusMail, |
969
|
|
|
'form' => $form, |
970
|
|
|
'socialLinkUrl' => $socialLinkUrl, |
971
|
|
|
'post' => $post |
972
|
|
|
)); |
973
|
|
|
|
974
|
|
|
return $viewModel; |
975
|
|
|
} |
976
|
|
|
|
977
|
|
|
public function getGameService() |
978
|
|
|
{ |
979
|
|
|
if (!$this->gameService) { |
980
|
|
|
$this->gameService = $this->getServiceLocator()->get('playgroundgame_postvote_service'); |
|
|
|
|
981
|
|
|
} |
982
|
|
|
|
983
|
|
|
return $this->gameService; |
984
|
|
|
} |
985
|
|
|
} |
986
|
|
|
|
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: