1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PlaygroundGame\Form\Admin; |
4
|
|
|
|
5
|
|
|
use PlaygroundCore\Stdlib\Hydrator\DoctrineObject as DoctrineHydrator; |
6
|
|
|
use Zend\Mvc\I18n\Translator; |
7
|
|
|
use Zend\ServiceManager\ServiceManager; |
8
|
|
|
|
9
|
|
|
class PostVote extends Game |
10
|
|
|
{ |
11
|
|
|
public function __construct($name, ServiceManager $sm, Translator $translator) |
12
|
|
|
{ |
13
|
|
|
$this->setServiceManager($sm); |
14
|
|
|
$entityManager = $sm->get('doctrine.entitymanager.orm_default'); |
15
|
|
|
|
16
|
|
|
// Mapping of an Entity to get value by getId()... Should be taken in charge by Doctrine Hydrator Strategy... |
17
|
|
|
// having to fix a DoctrineModule bug :( https://github.com/doctrine/DoctrineModule/issues/180 |
18
|
|
|
$hydrator = new DoctrineHydrator($entityManager, 'PlaygroundGame\Entity\PostVote'); |
|
|
|
|
19
|
|
|
$hydrator->addStrategy('partner', new \PlaygroundCore\Stdlib\Hydrator\Strategy\ObjectStrategy()); |
20
|
|
|
$this->setHydrator($hydrator); |
21
|
|
|
|
22
|
|
|
parent::__construct($name, $sm, $translator); |
23
|
|
|
|
24
|
|
|
$this->add(array( |
25
|
|
|
'type' => 'Zend\Form\Element\Select', |
26
|
|
|
'name' => 'postDisplayMode', |
27
|
|
|
'attributes' => array( |
28
|
|
|
'id' => 'postDisplayMode', |
29
|
|
|
'options' => array( |
30
|
|
|
'date' => $translator->translate('Date', 'playgroundgame'), |
31
|
|
|
'vote' => $translator->translate('Vote number', 'playgroundgame'), |
32
|
|
|
'random' => $translator->translate('Random', 'playgroundgame'), |
33
|
|
|
), |
34
|
|
|
), |
35
|
|
|
'options' => array( |
36
|
|
|
'empty_option' => $translator->translate('Display posts orber by', 'playgroundgame'), |
37
|
|
|
'label' => $translator->translate('Posts display mode', 'playgroundgame'), |
38
|
|
|
), |
39
|
|
|
)); |
40
|
|
|
|
41
|
|
|
$this->add(array( |
42
|
|
|
'type' => 'Zend\Form\Element\Text', |
43
|
|
|
'name' => 'postDisplayNumber', |
44
|
|
|
'attributes' => array( |
45
|
|
|
'id' => 'postDisplayNumber', |
46
|
|
|
), |
47
|
|
|
'options' => array( |
48
|
|
|
'empty_option' => $translator->translate('Number of displayed posts', 'playgroundgame'), |
49
|
|
|
'label' => $translator->translate('Number of displayed posts', 'playgroundgame'), |
50
|
|
|
), |
51
|
|
|
)); |
52
|
|
|
|
53
|
|
|
$this->add(array( |
54
|
|
|
'type' => 'Zend\Form\Element\Checkbox', |
55
|
|
|
'name' => 'voteAnonymous', |
56
|
|
|
'options' => array( |
57
|
|
|
'label' => $translator->translate('Allow anonymous visitors to vote', 'playgroundgame'), |
58
|
|
|
), |
59
|
|
|
)); |
60
|
|
|
|
61
|
|
|
$this->add(array( |
62
|
|
|
'type' => 'Zend\Form\Element\Select', |
63
|
|
|
'name' => 'moderationType', |
64
|
|
|
'attributes' => array( |
65
|
|
|
'id' => 'moderationType', |
66
|
|
|
'options' => array( |
67
|
|
|
'0' => $translator->translate('Post moderation', 'playgroundgame'), |
68
|
|
|
'1' => $translator->translate('Pre moderation', 'playgroundgame'), |
69
|
|
|
), |
70
|
|
|
), |
71
|
|
|
'options' => array( |
72
|
|
|
'empty_option' => $translator->translate('Moderation type', 'playgroundgame'), |
73
|
|
|
'label' => $translator->translate('Moderation type', 'playgroundgame'), |
74
|
|
|
), |
75
|
|
|
)); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: