Rovak / KJSencha

Ext-JS / Sencha Touch Integration Module for Zend Framework 2
Other
24 stars 15 forks source link

Direct Service retrieve data from a controller action #32

Closed smhagit closed 10 years ago

smhagit commented 10 years ago

Hello,

I'm trying to use the KJSencha Module, specially to display nice Ext.JS Forms. In my Application Module I have a \Direct\Form\UserForm.php which provides some user informations in my Ext.JS Form.

Thats working great, BUT in my UserForm Service I don't have access to ServiceManager, EventManager, etc...

I would like to dispatch a Controller Action and returning the response. In KJSencha\Controller\DirectController::dispatchRPC you call

$response['result'] = call_user_func_array(array($object, $rpc->getMethod()), $rpc->getData());

and I would have something like this:

$retVal = $this->forward()->dispatch('Application\Controller\User', array("action" => "getUserProfile"));

Is this possible? I'm a beginner with Ext.JS and ZF2.

Thanks for your help!

Rovak commented 10 years ago

Hi RobbyVoid,

I wrote a test to demonstrate how the ServiceManager and EventManager can be referenced from a Direct Action, the Direct needs to implement the ServiceLocatorAwareInterface in order to use the ServIceManager.

The example can be found here: https://github.com/Rovak/KJSencha/blob/develop/tests/KJSenchaTestAsset/Direct/ServiceAction.php#L30

Rovak commented 10 years ago

@RobbyVoid, did the above example answer your question?