Issue Type: Bug Created: 2009-08-13T11:30:56.000+0000 Last Updated: 2011-05-13T20:56:03.000+0000 Status: Open Fix version(s): Reporter: Chris Priebe (chris.priebe) Assignee: Wade Arnold (wadearnold) Tags: - Zend_Amf
Related issues: - ZF-5393
Attachments: - reuse_objects_in_set_class.patch
I need to set paramets into the __constructor of my PHP object before passing it off to Zend to use it as a Remote Procedure Call.
This works in Zend_Json but not in Zend_Amf. To do this with the Zend_JSON class I just create my object and pass it along as $this->server->setClass($object) and it will use that object in Zend/Server/Abstract.php method _displatch for $object = $invocable->getObject();
Instead the Zend_Amf_Server class overrides the Abstract _dispatch call and ignores the class I passed it. Instead it always calls $object = $info->getDeclaringClass()->newInstance();
Thus is creates a new instance and I am unable to use dependancy injection to establish my object.
Posted by Georg Wächter (georgwaechter) on 2010-03-16T14:00:16.000+0000
i ran into the same problem as i use dependency injection for my objects too. I wrote a simple patch that solves this issue. Please have a look ...
Posted by Georg Wächter (georgwaechter) on 2010-03-16T14:00:48.000+0000
the patch attached
Posted by Wade Arnold (wadearnold) on 2010-03-18T10:52:55.000+0000
Any ideas for a good way of writing a test case for this behavior?
Posted by Georg Wächter (georgwaechter) on 2010-03-18T11:20:12.000+0000
yes, i'm going to write one or two unit tests ..
Posted by Georg Wächter (georgw) on 2011-05-13T20:56:03.000+0000
Ok. The patch is now more than one year old and sadly i hadn't the time to setup the full Zend Framework develpoment environment together with its unit tests to write another one for this use case.
But as the comments of the implemented Zend Server Interface state the setClass method behaves currently not as expected. Passing objects should be a valid option. I appreciate if we could commit this patch to trunk.
By the way i'll contribute another patch that fixes this behavior for Zend_Rest_Server too!
Have you found an issue?
See the Overview section for more details.