|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
4
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
|
5
|
|
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
|
6
|
|
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
|
7
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
|
8
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace MpaCustomDoctrineHydrator\Form\Annotation; |
|
12
|
|
|
|
|
13
|
|
|
use Doctrine\Common\Persistence\ObjectManager; |
|
14
|
|
|
use DoctrineORMModule\Form\Annotation\AnnotationBuilder as DoctrineAnnotationBuilder; |
|
15
|
|
|
use Zend\EventManager\EventManagerInterface; |
|
16
|
|
|
use Zend\Form\Annotation\AnnotationBuilder as ZendAnnotationBuilder; |
|
17
|
|
|
use Zend\Form\Factory; |
|
18
|
|
|
use Zend\Form\FormElementManager; |
|
19
|
|
|
|
|
20
|
|
|
class AnnotationBuilder extends DoctrineAnnotationBuilder |
|
21
|
|
|
{ |
|
22
|
|
|
protected $formElementManager; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @param ObjectManager $objectManager |
|
26
|
|
|
* @param FormElementManager $formElementManager |
|
27
|
|
|
*/ |
|
28
|
4 |
|
public function __construct(ObjectManager $objectManager, FormElementManager $formElementManager) |
|
29
|
|
|
{ |
|
30
|
4 |
|
$this->objectManager = $objectManager; |
|
31
|
4 |
|
$this->formElementManager = $formElementManager; |
|
32
|
|
|
/** |
|
33
|
|
|
* We set the FEM as form factory so the ZF2 AnnotationBuilder |
|
34
|
|
|
* is aware of custom form elements names |
|
35
|
|
|
*/ |
|
36
|
4 |
|
$this->formFactory = new Factory($this->formElementManager); |
|
37
|
4 |
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* {@inheritDoc} |
|
41
|
|
|
*/ |
|
42
|
2 |
|
public function setEventManager(EventManagerInterface $events) |
|
43
|
|
|
{ |
|
44
|
2 |
|
ZendAnnotationBuilder::setEventManager($events); |
|
45
|
|
|
|
|
46
|
2 |
|
$this->getEventManager() |
|
47
|
2 |
|
->attach(new ElementAnnotationsListener($this->objectManager, $this->formElementManager)); |
|
|
|
|
|
|
48
|
|
|
|
|
49
|
2 |
|
return $this; |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|
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: