Download & Extend

explicitType for Typed objects in Flex (with patch)

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.

AttachmentSize
amfphp.patch960 bytes
vo.zip701 bytes

Comments

#1

Yes.

This is very useful for serialization/deserialization.

Why this is not implemented by default in the AMFPHP project ?

#2

Status:active» needs work

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:

<?php
function 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:

  • 1st file: Generic.jpg. This is datas displayed in the eclipse debugger raw from AMFPHP gateway. We can observe that type is a native AS3 Object.
  • 2nd file: Semi typed Object.jpg. This is datas returned with jrowny version of AMFPHP gateway. We can observe that the classmapping is well done, the object is a strongly typed object: teo.vo.Gallery. In AS3 the only code we need is to create the VO class, and call 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.

  • 3rd file: Fully typed Object.jpg. When native deserializing in flash append, the implicite getter and setter create new FileField typed Object, you can look in the debugger that you then get a fully typed Object. This can be fully native as well, but we need to 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

AttachmentSize
Generic.jpg 652.51 KB
Semi typed Object.jpg 643.61 KB
Fully typed Object.jpg 718.99 KB
nobody click here