public function decode($data) { $this->init(); require_once $this->path . 'InputStream.php'; require_once $this->path . 'Amf3/Deserializer.php'; $stream = new Zend_Amf_Parse_InputStream(substr($data, 1)); $deserializer = new Zend_Amf_Parse_Amf3_Deserializer($stream); return $deserializer->readTypeMarker(); }
/** * Deserialize an AMF3 value to PHP * * @param mixed $value * @param array $opts * @return string * @throws Zend_Serializer_Exception */ public function unserialize($value, array $opts = array()) { try { $stream = new Zend_Amf_Parse_InputStream($value); $deserializer = new Zend_Amf_Parse_Amf3_Deserializer($stream); return $deserializer->readTypeMarker(); } catch (Exception $e) { throw new Zend_Serializer_Exception('Unserialization failed by previous error', 0, $e); } }
/** * Read an object from the AMF stream and convert it into a PHP object * * @todo Rather than using an array of traitsInfo create Zend_Amf_Value_TraitsInfo * @return object|array */ public function readObject() { $returnObject = parent::readObject(); /*if ($returnObject instanceof \Doctrine\Common\Collections\ArrayCollection) { // If the object we are deserializing is an ArrayCollection we need to set its contents to externalizedData $returnObject->__construct($returnObject->externalizedData); }*/ /*if ($returnObject instanceof \Flextrine\Collections\FlextrinePersistentCollection) { // If the object we are deserializing is an FlextrinePersistentCollection we need to set its contents to source // TODO: This could maybe be done in __set instead... $returnObject->__construct($returnObject->source); }*/ return $returnObject; }
/** * AMF3 data type encountered load AMF3 Deserializer to handle * type markers. * * @return string */ public function readAmf3TypeMarker() { require_once PHP_LIBRARY_PATH . 'Zend/Amf/Parse/Amf3/Deserializer.php'; $deserializer = new Zend_Amf_Parse_Amf3_Deserializer($this->_stream); $this->_objectEncoding = Zend_Amf_Constants::AMF3_OBJECT_ENCODING; return $deserializer->readTypeMarker(); }
public function getData() { $data = file_get_contents('php://input'); if ($this->format == RestFormat::AMF) { require_once 'Zend/Amf/Parse/InputStream.php'; require_once 'Zend/Amf/Parse/Amf3/Deserializer.php'; $stream = new Zend_Amf_Parse_InputStream($data); $deserializer = new Zend_Amf_Parse_Amf3_Deserializer($stream); $data = $deserializer->readTypeMarker(); } else { $data = json_decode($data); } return $data; }
/** * AMF3 data type encountered load AMF3 Deserializer to handle * type markers. * * @return string */ public function readAmf3TypeMarker() { $deserializer = new Zend_Amf_Parse_Amf3_Deserializer($this->_stream); $this->_objectEncoding = Zend_Amf_Constants::AMF3_OBJECT_ENCODING; return $deserializer->readTypeMarker(); }