/** * deserialize * @see Amfphp_Core_Common_IDeserializer * @param array $getData * @param array $postData * @param string $rawPostData * @return string */ public function deserialize(array $getData, array $postData, $rawPostData) { $deserializer = new Amfphp_Core_Amf_Deserializer(); //note: this has to be done here and not in the constructor to avoid //disabling scanning when it's another handler that ends up handling the request $this->voConverter = Amfphp_Core_FilterManager::getInstance()->callFilters(Amfphp_Core_Gateway::FILTER_VO_CONVERTER, null); if ($this->voConverter) { $this->voConverter->setScanEnabled(false); $deserializer->voConverter = $this->voConverter; } $requestPacket = $deserializer->deserialize($getData, $postData, $rawPostData); return $requestPacket; }
/** * tries to use the type to get a typed object. If not possible, return a stdClass, * with the explicit type marker set if the type was not just an empty string * @param type $typeIdentifier * @return stdClass or typed object */ protected function resolveType($typeIdentifier) { if ($typeIdentifier != '') { if ($this->voConverter) { $obj = $this->voConverter->getNewVoInstance($typeIdentifier); } else { $obj = new stdClass(); $explicitTypeField = Amfphp_Core_Amf_Constants::FIELD_EXPLICIT_TYPE; $obj->{$explicitTypeField} = $typeIdentifier; } } else { $obj = new stdClass(); } return $obj; }
/** * write amf 3 data * @todo no type markers ("\6', for example) in this method! * @param mixed $d */ protected function writeAmf3Data($d) { if (is_int($d)) { //int $this->writeAmf3Number($d); return; } elseif (is_float($d)) { //double $this->outBuffer .= ""; $this->writeDouble($d); return; } elseif (is_string($d)) { // string $this->outBuffer .= ""; $this->writeAmf3String($d); return; } elseif (is_bool($d)) { // boolean $this->writeAmf3Bool($d); return; } elseif (is_null($d)) { // null $this->writeAmf3Null(); return; } elseif ($d instanceof Amfphp_Core_Amf_Types_Undefined) { // undefined $this->writeAmf3Undefined(); return; } elseif ($d instanceof Amfphp_Core_Amf_Types_Date) { // date $this->writeAmf3Date($d); return; } elseif (is_array($d)) { // array $this->writeAmf3Array($d); return; } elseif ($d instanceof Amfphp_Core_Amf_Types_ByteArray) { //byte array $this->writeAmf3ByteArray($d); return; } elseif ($d instanceof Amfphp_Core_Amf_Types_Xml) { // Xml $this->writeAmf3Xml($d); return; } elseif ($d instanceof Amfphp_Core_Amf_Types_XmlDocument) { // XmlDoc $this->writeAmf3XmlDocument($d); return; } elseif ($d instanceof Amfphp_Core_Amf_Types_Vector) { $this->writeAmf3Vector($d); return; } elseif (is_object($d)) { if ($this->voConverter) { $this->voConverter->markExplicitType($d); } $explicitTypeField = Amfphp_Core_Amf_Constants::FIELD_EXPLICIT_TYPE; if (isset($d->{$explicitTypeField})) { $this->writeAmf3TypedObject($d); return; } else { $this->writeAmf3AnonymousObject($d); return; } } throw new Amfphp_Core_Exception("couldn't write object " . print_r($d, false)); }