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.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | Generic.jpg | 652.51 KB | sylvain lecoy |
| #3 | Semi typed Object.jpg | 643.61 KB | sylvain lecoy |
| #3 | Fully typed Object.jpg | 718.99 KB | sylvain lecoy |
| vo.zip | 701 bytes | jrowny | |
| amfphp.patch | 960 bytes | jrowny |
Comments
Comment #1
sylvain lecoy commentedYes.
This is very useful for serialization/deserialization.
Why this is not implemented by default in the AMFPHP project ?
Comment #2
snelson commentedI 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:
If someone can fire this up an test with other services that return nodes, I'd be happy to review and commit.
Comment #3
sylvain lecoy commentedI 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