If you’re working on integrating Doctrine and AMF, here’s a little trick that may help save you some steps in type mapping your results. NOTE: This only works for Zend_Amf and not AMFPHP. There seems to be a serialization problem with AMFPHP that I’ve yet to figure out.
Keep in mind the Doctrine Manual has you do this in the setTableDefinition() function but that doesn’t seem to work. Make sure it’s in the constructor of your generated models instead.
class Widget extends BaseWidget { public function construct(){ $this->mapValue("_explicitType","com.domain.vo.WidgetVO"); } } |
Now when you pass results from Doctrine through AMF, the “_explictType” property will be set and your receiving end will see them as the intended typed object and not Proxy objects. We could have also put this in the BaseWidget Class instead too.
Thanks, it was vaery helpfull for me.
I have just released an open-source Flex ORM solution using Doctrine 2 – check it out at http://www.flextrine.com
Dave Keen
http://www.actionscriptdeveloper.co.uk
Hey Dave, Flextrine looks pretty awesome! We’ll have to trade notes sometime. I actually work on the Aerial/CMS project which is also a Flex/Doctrine ORM implementation.
I’m having the same problem using Doctrine 1.2.2 and Zend Amf 1.10.7 except that it didn’t work no matter what I tried : using your method (constructor), setTableDefinition, getASClassName(), wether it be in the Contact or BaseContact and with or without setClassMap(‘ContactVO’,'Contact’) on Zend Amf bootstrap (even tried with the fully qualified class name there). And I’m sure there’s no error left as I received my service response correctly (without class mapping) and set my Flex RemoteClass metadata.
Could you give me any advice on how to proceed ?
This is necessary for me because my website has quite a huge database and class mapping is really needed there
Thanks a lot, hope you’ll get time for this.
Hi Romain, I haven’t tried with Zend Amf 1.10 as I’ve switched back to AMFPHP. Can you provide some code for me to test with? All I need is a single Flex VO and the associated PHP Service class (and base). If I don’t see any errors, I’ll see if I can get a full round-trip example working with Zend 1.10 and zip it up for you. You can either paste the code here or email it to me: robert@[this domain]
Hi Rob,
I have a fairly large amfphp project, and I’m looking to use doctrine as an ORM.
I’ve managed to hook up my services folder, so that any doctrine queries are passed off to the relevant doctrine models, and this all works fine. The one outstanding item is to get the VO’s working correctly. I tried to use something like the following in my doctrine model, but amfphp doesnt seem to recognise this, and the array doesnt get typed up properly at all.
class ModelUser extends ModelBaseUser{
public function construct()
{
$this->mapValue("_explicitType", 'UserVO');
}
}
Any pointers on how to get VO’s working with amfphp and doctrine would be awesome.
Hey JonoB, does you UserVO class in Flex have the RemoteClass alias set like the following?:
[RemoteClass(alias="UserVO")]
public class UserVO extends BaseUserVO
{
public function UserVO()
{
}
}
The RemoteClass alias and your PHP mapValue can actually be anything as long as they match EXACTLY. Even prefixing with the package as such: alias=”model.vo.UserVO” would break it because mapValue=”UserVO”.
Also, are you using a tool like http://www.charlesproxy.com? There’s also a Firefox add-on equivalent called “AMF Explorer”. These will allow you to monitor the AMF request and response traffic between PHP and Flex; giving you a better look into what might be wrong or missing.