Flex object not typed correctly

62 Views Asked by At

I'm struggling to get a flex class instance back to Amfphp (v2.2)

Simplified code in Flex:

    [RemoteClass(alias="Project")]
    public class Project
    {
        public function Project()
        {
        }
    }

Code in php:

    class Project {
        var $_explicitType = "Project";

        public function foo()
        {
            return "bar";
        }
    }

At a point, I send this code to the server:

myRemoteObjectService.testMethod(myProjectInstance);

Which is handled in php like this:

    public function testMethod($projectInstance)
    {
        return $projectInstance->foo;
    }

This should return 'bar' to my Flex application but instead, I get

faultCode:Channel.Call.Failed faultString:'error' faultDetail:'NetConnection.Call.Failed: HTTP: Status 500'

What DOES work is:

    public function testMethod()
    {
        $project = new Project();
        return $project->foo;
    }

Any help would be very appreciated!

Dany

2

There are 2 best solutions below

0
Dany Dhondt On

Found the answer: The standard location for vo objects is /Services/Vo/ In my case, my vo objects where in /dto/ When I put all my vo objects into /Services/Vo/, everything worked as expected.

BUT

I tried setting /dto/ in config using:

$this->voFolders = array(AMFPHP_ROOTPATH . 'dto/');

And that didn't work. So:

  • I'm glad to have solved the question
  • Is this a bug in the Amfphp config?
0
Ariel Sommeria-Klein On

Vo conversion is handled by the Vo converter plugin. IT's described here http://www.silexlabs.org/amfphp/documentation/plugins/plugins-distributed-with-amfphp/vo-converter/ Try something like this in your config

$this->pluginsConfig["AmfphpCustomClassConverter"] = array(“customClassFolderPaths” => array(AMFPHP_ROOTPATH . “MyVoFolder”));