New version - new features - coming soon!
Quote:
Originally Posted by
netsuo
Sorry to have taken your time away. Rest assured I will report anything (real) I'll found about your ExtDirect, because I'll use it extensively the next weeks in a project I'm starting right now.
Thanks a lot to have taken some time to help me, it definately gave me some advice on my problem !
No problem. In fact, I thank the opportunity to share here in the forums a bit more information about "ExtDirect.php" internals. Also, each post makes the thread stay on top of the latest updated! :)
I thought the cause of your problem could be also something related to the "header" command in ExtDirectController::output... but now you already found the real cause.
I am using this "ExtDirect.php" in a project I am developing right now. More features were recently added! So, soon I will upload a new version.
Basically, three new configuration options were added, all of callback type: "authorization_function", "transform_result_function", and "transform_response_function"
You will be able to specify an "authorization_function", where you can check the user permissions and return true or false accordingly, allowing the API call or not.
With the "transform_result_function", you can modify the result of the API method call after its execution, but before it is sent to the client-side.
Finally, with the "transform_response_function", you can modify the response structure. This allows to fire server-side events! But I am not using this feature for it. I am using it to send extra server side data together with the RPC result.
So... stay tuned!
CYO
How to access the returned data?
OK, it's been a long day, I'm just back off my hols, and I'm new to this kind of complex JS, so I can't work this one out.
I've got the extdirect code working absolutely fine. But I'm having problems accessing the returned data FROM OUTSIDE THE EXTDIRECT CALL...
Here's the relevant code:
Code:
var plugins = ['plugin1', 'plugin2'];
var input="Anyone there? " ;
var hook='test';
function executeHook(hook, input) {
var output = "";
Ext.php.PluginManager.executeHooks(plugins, hook, input, function(data) {
console.info("DEBUG WITHIN FUNCTION: " + data);
output = data;
});
return output;
}
console.info("RESULT FROM FUNCTION:" + executeHook(hook, input));
Each plugin simply adds a piece of test to the input, in a chain. So the output should be:
"Anyone there? Hello from core; Hello from plugin 2; Hello from plugin 1; "
However, the console has the two output lines as follows:
"RESULT FROM FUNCTION:"
"DEBUG WITHIN FUNCTION: Anyone there? Hello from core; Hello from plugin 2; Hello from plugin 1; "
So the variable data is correct within the ExtDirect call, but how do I get access to the data outside the ExtDirect call?
I've also tried:
Code:
Ext.php.PluginManager.executeHooks(plugins, hook, input, function(data) {
console.info("DEBUG WITHIN FUNCTION: " + data);
return data;
});
But that produces the same result.
Any ideas?
Regards,
Andy