| Project: | AMFPHP |
| Version: | 6.x-1.0-beta1 |
| Component: | Miscellaneous |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Issue Summary
I've created a patch to set explicitType to node->type. This is very useful because you can then set create an ASObject VO with RemoteClass(alias="node") or RemoteClass(alias="page") and it will automatically work, assuming identical properties. I've also attached to VOs that should work for node.get() with a page.
I only tested this for node.get() on AMFPHP 6.1 beta with Drupal 6.10! I don't know if it works for views.
In the future, this needs to be an option that you can check off like "Do you want to set ExplicitType?" and I think you should also be able to override it to any value you like. I am not good enough at Drupal to do this on my own.
I am also planning to release a SWC with some useful tools for dealing with Flex/Drupal apps, including the default VO set.
If anyone's interesting, I'm giving a presentation about this stuff today at DrupalCon.
| Attachment | Size |
|---|---|
| amfphp.patch | 960 bytes |
| vo.zip | 701 bytes |
Comments
#1
Yes.
This is very useful for serialization/deserialization.
Why this is not implemented by default in the AMFPHP project ?
#2
I like this. However, I'm unsure about the performance implications of attached patched, looping through all data yet again. hook_nodeapi might be a better approach.
Something like:
<?phpfunction amfphp_nodeapi(&$node, $op,) {
switch ($op) {
case 'load':
$node->_explicitType = $node->type;
break;
}
}
?>
If someone can fire this up an test with other services that return nodes, I'd be happy to review and commit.
#3
I will test your code.
The code provided by jrowny is not optimized at all, but I retrieve an already typed object and that's works well... except for ckk fields, I get an generic Object in flash, but that's normal, no cck fields are registered as php objects.
With your hook_nodeapi function, I get a NetConnection.Call.BadVersion error from AMF Server. Which means there is a php error.
look at my files for better understanding:
registerClassAlias("gallery", teo.vo.Gallery);If we look deeper, we can observe that cck fields are generic AS3 Objects.. This is normal because there is no fields called type in the php side. So the flash work-arround is described in the thrid file.
registerClassAlias("cck.FileField", web.domains.drupal6.models.vo.cck.FileField);in my example, and in php side, FileField has to be recognized and _explicitType set to "cck.FileField".Why not implementing a set of common typed object, such as "drupal.Node", "drupal.cck.FileField", etc.. and use custom types when building new kind of content ?
Then all datas comes already typed and that's a beautiful thing.
I can test all you want in the flash side, unfortunately, I know remoting only with BlazeDS and my expertise is ActionScript/Java/C++ (no PHP). But I have lot of ideas to improve the Service and especially AMFPHP module, thank you snelson for developping and maintaining this module.
And I appologize for my english, I'm french so tell me if there is unclear props.
Sylvain