/** * getLocalClassName * * @param string $remoteClass * @return mixed */ protected function getLocalClassName($remoteClass) { return SabreAMF_ClassMapper::getLocalClass($remoteClass); }
/** * readObject * * @return object */ public function readObject() { $objInfo = $this->readInt(); $storedObject = ($objInfo & 0x1) == 0; $objInfo = $objInfo >> 1; if ($storedObject) { $objectReference = $objInfo; if (!isset($this->storedObjects[$objectReference])) { throw new Exception('Object reference #' . $objectReference . ' not found'); } else { $rObject = $this->storedObject[$objectReference]; } } else { $storedClass = ($objInfo & 0x1) == 0; $objInfo = $objInfo >> 1; // If this is a stored class.. we have the info if ($storedClass) { $classReference = $objInfo; if (!isset($this->storedClasses[$classReference])) { throw new Exception('Class reference #' . $classReference . ' not found'); } else { $encodingType = $this->storedClasses[$classReference]['encodingType']; $propertyNames = $this->storedClasses[$classReference]['propertyNames']; $className = $this->storedClasses[$classReference]['className']; } } else { $className = $this->readString(); $encodingType = $objInfo & 0x3; $propertyNames = array(); $objInfo = $objInfo >> 2; } //ClassMapping magic if ($className) { if ($localClassName = SabreAMF_ClassMapper::getLocalClass($className)) { $rObject = new $localClassName(); } else { $rObject = new SabreAMF_TypedObject($className, array()); } } else { $rObject = new STDClass(); } $this->storedObjects[] =& $rObject; if ($encodingType & SabreAMF_AMF3_Const::ET_EXTERNALIZED) { if (!$storedClass) { $this->storedClasses[] = array('className' => $className, 'encodingType' => $encodingType, 'propertyNames' => $propertyNames); } if ($rObject instanceof SabreAMF_Externalized) { $rObject->readExternal($this->readAMFData()); } elseif ($rObject instanceof SabreAMF_TypedObject) { $rObject->setAMFData(array('externalizedData' => $this->readAMFData())); } else { $rObject->externalizedData = $this->readAMFData(); } //$properties['externalizedData'] = $this->readAMFData(); } else { if ($encodingType & SabreAMF_AMF3_Const::ET_SERIAL) { if (!$storedClass) { $this->storedClasses[] = array('className' => $className, 'encodingType' => $encodingType, 'propertyNames' => $propertyNames); } $properties = array(); do { $propertyName = $this->readString(); if ($propertyName != "") { $propertyNames[] = $propertyName; $properties[$propertyName] = $this->readAMFData(); } } while ($propertyName != ""); } else { if (!$storedClass) { $propertyCount = $objInfo; for ($i = 0; $i < $propertyCount; $i++) { $propertyNames[] = $this->readString(); } $this->storedClasses[] = array('className' => $className, 'encodingType' => $encodingType, 'propertyNames' => $propertyNames); } $properties = array(); foreach ($propertyNames as $propertyName) { $properties[$propertyName] = $this->readAMFData(); } } if ($rObject instanceof SabreAMF_TypedObject) { $rObject->setAMFData($properties); } else { foreach ($properties as $k => $v) { if ($k) { $rObject->{$k} = $v; } } } } } return $rObject; }