Zend Framework 2 - Hydrator 策略没有响应和保湿

我基本上实施了这个策略.

主要区别是(我猜)我使用 Doctrine2.

The main difference is (I guess) that I use Doctrine2.

构造函数类被调用(打印测试回显)但两个函数extract()hydrate() 没有被调用.

The constructor class is called (a test echo is printed) but the two functions extract() and hydrate() are not.

我添加的策略如下:

$hydrator = new DoctrineEntity($entityManager);
$hydrator->getHydrator()->addStrategy('my_attribute', new MyHydrationStrategy());
$form->setHydrator($hydrator);

此处发布了一个类似的问题.

也许问题在于我如何添加此策略.但老实说我不知道​​...

Maybe the problem is in the way how I add this strategy. But I honestly don't know...

如果有人能给我提示我做错了什么就好了.

Would be great if somebody could give me a hint what I'm doing wrong.

推荐答案

请参考这篇文章,以获得更简洁、更合适的解决方案!

Please refer to this post, for a cleaner and more appropriate solution!

Zend 框架 2 - Hydrator教义关系的策略不起作用

相关文章