Zend AMF定制调度程序 [英] Zend AMF custom dispatcher

查看:107
本文介绍了Zend AMF定制调度程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Zend_AMF时是否可以使用自定义调度程序?



我知道我可以将类名或对象传递给Zend_AMF的setClass()。 / p>

但是,当我将一个对象传递给setClass时,它似乎没有存储该对象的副本。相反,它会计算出类名,然后实例化对象本身的副本。



这是一个问题,因为我使用了yadif依赖项注入容器。对象应该使用构造函数依赖关系和/或属性依赖关系进行实例化。



由于Zend_Amf调度程序完成了所有实例化,因此无法将构造函数依赖关系和其他依赖关系注入到我的实例中。对象。



如果有人对我可以克服这一问题而又不触及Zend_AMF中的任何代码有一个策略,那就太好了:)

解决方案

解决方案是基本上围绕Zend_Amf构建一个包装器。编写方式意味着我必须复制handle和_handle()方法中的大多数代码。然后,我不得不修改一些调用的方法,以指向我创建的Zend_Amf的实例。



最后,更改了分派,以便调用了我自己的分派器,并且结果返回了。



显然不是最优雅的解决方案,但希望他们可以对Zend_AMF进行​​改编,使其在将来更具可扩展性,并让我们能够更轻松地进行使用。



目前,我仍然可以轻松将Zend_AMF的更新版本放入我的 vendors文件夹中,而无需修改任何代码。


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 :)

解决方案

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.

这篇关于Zend AMF定制调度程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆