Zend AMF 自定义调度程序
使用 Zend_AMF 时是否可以使用自定义调度程序?
我知道我可以将类名或对象传递给 Zend_AMF 的 setClass() 。
但是,当我将一个对象传递给 setClass 时,它似乎没有存储该对象的副本。相反,它计算出类名,然后实例化对象本身的副本。
这是一个问题,因为我使用 yadif 依赖注入容器。应使用构造函数依赖项和/或属性依赖项来实例化对象。
由于 Zend_Amf 调度程序完成所有实例化,因此我无法将构造函数依赖项和其他依赖项注入到我的对象中。
如果有人有一个策略告诉我如何在不接触 Zend_AMF 中任何代码的情况下克服这个问题,那就太好了:)
Is it possible to use a custom dispatcher when using Zend_AMF?
I know I can pass either a class name or an object to setClass() for Zend_AMF.
However, when I pass an object to setClass, it does not seem to store a copy of that object. Instead it worksout the class name and then instantiates a copy of the object itself.
This is a problem as I use the yadif dependency injection container. Objects should be instantiated with constructor dependencies and/or property dependencies.
Since the Zend_Amf dispatcher does all the instantiating, I am not able to inject constructor dependencies and other dependencies to my objects.
If anyone has a strategy as to how I can overcome this without touching any of the code in Zend_AMF, that would be great :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案基本上是围绕 Zend_Amf 构建一个包装器。它的编写方式意味着我必须复制 handle 和 _handle() 方法中的大部分代码。然后我必须修改一些调用的方法以指向我创建的 Zend_Amf 实例。
最后改变了调度,调用了我自己的调度器,结果返回了。
显然这不是最优雅的解决方案,但希望他们将来能够重新设计 Zend_AMF,使其更具可扩展性,并允许我们更轻松地使用它。
目前,我仍然可以轻松地将 Zend_AMF 的更新版本放入我的“vendors”文件夹中,而无需修改任何代码。
The solution is to basically build a wrapper around Zend_Amf. The way it is written means that I had to copy most of the code in the handle and _handle() methods. I then had to modify some called methods to point to an instance of Zend_Amf I have created.
Finally, the dispatching was changed so that my own dispatcher was called, and the results returned.
Obviously not the most elegant solution, but hopefully they will rework Zend_AMF to be a bit more extensible in the future and allow us to hook into it much easily.
At the moment, I can still easily drop in an updated version of Zend_AMF into my "vendors" folder without modifying any of the code.