/** * Read Class that is to be mapped to a server class. * * Commonly used for Value Objects on the server * * @todo implement Typed Class mapping * @return object|array * @throws \fproject\amf\AmfException if unable to load type */ public function readTypedObject() { // get the remote class name $className = $this->_stream->readUTF(); $loader = TypeLoader::loadType($className); $returnObject = new $loader(); $properties = get_object_vars($this->readObject()); foreach ($properties as $key => $value) { if ($key) { $returnObject->{$key} = $value; } } if ($returnObject instanceof ArrayCollection) { $returnObject = get_object_vars($returnObject); } return $returnObject; }
public function testUnknownClassMap() { $class = TypeLoader::loadType('com.example.vo.Bogus'); $this->assertEquals('stdClass', $class); }
/** * @param $className * @return array * @throws \fproject\amf\AmfException */ protected function createObjectInstance($className) { // We now have the object traits defined in variables. Time to go to work: if (!$className) { // No class name generic object $returnObject = new \stdClass(); } else { // Defined object // Typed object lookup against registered classname maps if ($loader = TypeLoader::loadType($className)) { $returnObject = new $loader(); $className = $loader; } else { //user defined typed object $this->throwAmfException('Typed object not found: {0}', [$className]); } } return ['object' => $returnObject, 'className' => $className]; }