adding zend project folders into old campcaster.
This commit is contained in:
parent
56abfaf28e
commit
7ef0c18b26
4045 changed files with 1054952 additions and 0 deletions
306
library/Zend/Amf/Parse/Amf0/Deserializer.php
Normal file
306
library/Zend/Amf/Parse/Amf0/Deserializer.php
Normal file
|
@ -0,0 +1,306 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse_Amf0
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Deserializer.php 21210 2010-02-27 10:37:39Z yoshida@zend.co.jp $
|
||||
*/
|
||||
|
||||
/** Zend_Amf_Constants */
|
||||
require_once 'Zend/Amf/Constants.php';
|
||||
|
||||
/** @see Zend_Amf_Parse_Deserializer */
|
||||
require_once 'Zend/Amf/Parse/Deserializer.php';
|
||||
|
||||
/**
|
||||
* Read an AMF0 input stream and convert it into PHP data types
|
||||
*
|
||||
* @todo Implement Typed Object Class Mapping
|
||||
* @todo Class could be implemented as Factory Class with each data type it's own class
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse_Amf0
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Parse_Amf0_Deserializer extends Zend_Amf_Parse_Deserializer
|
||||
{
|
||||
/**
|
||||
* An array of objects used for recursively deserializing an object.
|
||||
* @var array
|
||||
*/
|
||||
protected $_reference = array();
|
||||
|
||||
/**
|
||||
* If AMF3 serialization occurs, update to AMF0 0x03
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_objectEncoding = Zend_Amf_Constants::AMF0_OBJECT_ENCODING;
|
||||
|
||||
/**
|
||||
* Read AMF markers and dispatch for deserialization
|
||||
*
|
||||
* Checks for AMF marker types and calls the appropriate methods
|
||||
* for deserializing those marker types. Markers are the data type of
|
||||
* the following value.
|
||||
*
|
||||
* @param integer $typeMarker
|
||||
* @return mixed whatever the data type is of the marker in php
|
||||
* @throws Zend_Amf_Exception for invalid type
|
||||
*/
|
||||
public function readTypeMarker($typeMarker = null)
|
||||
{
|
||||
if ($typeMarker === null) {
|
||||
$typeMarker = $this->_stream->readByte();
|
||||
}
|
||||
|
||||
switch($typeMarker) {
|
||||
// number
|
||||
case Zend_Amf_Constants::AMF0_NUMBER:
|
||||
return $this->_stream->readDouble();
|
||||
|
||||
// boolean
|
||||
case Zend_Amf_Constants::AMF0_BOOLEAN:
|
||||
return (boolean) $this->_stream->readByte();
|
||||
|
||||
// string
|
||||
case Zend_Amf_Constants::AMF0_STRING:
|
||||
return $this->_stream->readUTF();
|
||||
|
||||
// object
|
||||
case Zend_Amf_Constants::AMF0_OBJECT:
|
||||
return $this->readObject();
|
||||
|
||||
// null
|
||||
case Zend_Amf_Constants::AMF0_NULL:
|
||||
return null;
|
||||
|
||||
// undefined
|
||||
case Zend_Amf_Constants::AMF0_UNDEFINED:
|
||||
return null;
|
||||
|
||||
// Circular references are returned here
|
||||
case Zend_Amf_Constants::AMF0_REFERENCE:
|
||||
return $this->readReference();
|
||||
|
||||
// mixed array with numeric and string keys
|
||||
case Zend_Amf_Constants::AMF0_MIXEDARRAY:
|
||||
return $this->readMixedArray();
|
||||
|
||||
// array
|
||||
case Zend_Amf_Constants::AMF0_ARRAY:
|
||||
return $this->readArray();
|
||||
|
||||
// date
|
||||
case Zend_Amf_Constants::AMF0_DATE:
|
||||
return $this->readDate();
|
||||
|
||||
// longString strlen(string) > 2^16
|
||||
case Zend_Amf_Constants::AMF0_LONGSTRING:
|
||||
return $this->_stream->readLongUTF();
|
||||
|
||||
//internal AS object, not supported
|
||||
case Zend_Amf_Constants::AMF0_UNSUPPORTED:
|
||||
return null;
|
||||
|
||||
// XML
|
||||
case Zend_Amf_Constants::AMF0_XML:
|
||||
return $this->readXmlString();
|
||||
|
||||
// typed object ie Custom Class
|
||||
case Zend_Amf_Constants::AMF0_TYPEDOBJECT:
|
||||
return $this->readTypedObject();
|
||||
|
||||
//AMF3-specific
|
||||
case Zend_Amf_Constants::AMF0_AMF3:
|
||||
return $this->readAmf3TypeMarker();
|
||||
|
||||
default:
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Unsupported marker type: ' . $typeMarker);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read AMF objects and convert to PHP objects
|
||||
*
|
||||
* Read the name value pair objects form the php message and convert them to
|
||||
* a php object class.
|
||||
*
|
||||
* Called when the marker type is 3.
|
||||
*
|
||||
* @param array|null $object
|
||||
* @return object
|
||||
*/
|
||||
public function readObject($object = null)
|
||||
{
|
||||
if ($object === null) {
|
||||
$object = array();
|
||||
}
|
||||
|
||||
while (true) {
|
||||
$key = $this->_stream->readUTF();
|
||||
$typeMarker = $this->_stream->readByte();
|
||||
if ($typeMarker != Zend_Amf_Constants::AMF0_OBJECTTERM ){
|
||||
//Recursivly call readTypeMarker to get the types of properties in the object
|
||||
$object[$key] = $this->readTypeMarker($typeMarker);
|
||||
} else {
|
||||
//encountered AMF object terminator
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->_reference[] = $object;
|
||||
return (object) $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read reference objects
|
||||
*
|
||||
* Used to gain access to the private array of reference objects.
|
||||
* Called when marker type is 7.
|
||||
*
|
||||
* @return object
|
||||
* @throws Zend_Amf_Exception for invalid reference keys
|
||||
*/
|
||||
public function readReference()
|
||||
{
|
||||
$key = $this->_stream->readInt();
|
||||
if (!array_key_exists($key, $this->_reference)) {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Invalid reference key: '. $key);
|
||||
}
|
||||
return $this->_reference[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an array with numeric and string indexes.
|
||||
*
|
||||
* Called when marker type is 8
|
||||
*
|
||||
* @todo As of Flash Player 9 there is not support for mixed typed arrays
|
||||
* so we handle this as an object. With the introduction of vectors
|
||||
* in Flash Player 10 this may need to be reconsidered.
|
||||
* @return array
|
||||
*/
|
||||
public function readMixedArray()
|
||||
{
|
||||
$length = $this->_stream->readLong();
|
||||
return $this->readObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts numerically indexed actiosncript arrays into php arrays.
|
||||
*
|
||||
* Called when marker type is 10
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function readArray()
|
||||
{
|
||||
$length = $this->_stream->readLong();
|
||||
$array = array();
|
||||
while ($length--) {
|
||||
$array[] = $this->readTypeMarker();
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert AS Date to Zend_Date
|
||||
*
|
||||
* @return Zend_Date
|
||||
*/
|
||||
public function readDate()
|
||||
{
|
||||
// get the unix time stamp. Not sure why ActionScript does not use
|
||||
// milliseconds
|
||||
$timestamp = floor($this->_stream->readDouble() / 1000);
|
||||
|
||||
// The timezone offset is never returned to the server; it is always 0,
|
||||
// so read and ignore.
|
||||
$offset = $this->_stream->readInt();
|
||||
|
||||
require_once 'Zend/Date.php';
|
||||
$date = new Zend_Date($timestamp);
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert XML to SimpleXml
|
||||
* If user wants DomDocument they can use dom_import_simplexml
|
||||
*
|
||||
* @return SimpleXml Object
|
||||
*/
|
||||
public function readXmlString()
|
||||
{
|
||||
$string = $this->_stream->readLongUTF();
|
||||
return simplexml_load_string($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Zend_Amf_Exception if unable to load type
|
||||
*/
|
||||
public function readTypedObject()
|
||||
{
|
||||
require_once 'Zend/Amf/Parse/TypeLoader.php';
|
||||
// get the remote class name
|
||||
$className = $this->_stream->readUTF();
|
||||
$loader = Zend_Amf_Parse_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 Zend_Amf_Value_Messaging_ArrayCollection) {
|
||||
$returnObject = get_object_vars($returnObject);
|
||||
}
|
||||
return $returnObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* AMF3 data type encountered load AMF3 Deserializer to handle
|
||||
* type markers.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function readAmf3TypeMarker()
|
||||
{
|
||||
require_once '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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the object encoding to check if an AMF3 object
|
||||
* is going to be return.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getObjectEncoding()
|
||||
{
|
||||
return $this->_objectEncoding;
|
||||
}
|
||||
}
|
349
library/Zend/Amf/Parse/Amf0/Serializer.php
Normal file
349
library/Zend/Amf/Parse/Amf0/Serializer.php
Normal file
|
@ -0,0 +1,349 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse_Amf0
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Serializer.php 21210 2010-02-27 10:37:39Z yoshida@zend.co.jp $
|
||||
*/
|
||||
|
||||
/** Zend_Amf_Constants */
|
||||
require_once 'Zend/Amf/Constants.php';
|
||||
|
||||
/** @see Zend_Amf_Parse_Serializer */
|
||||
require_once 'Zend/Amf/Parse/Serializer.php';
|
||||
|
||||
/**
|
||||
* Serializer PHP misc types back to there corresponding AMF0 Type Marker.
|
||||
*
|
||||
* @uses Zend_Amf_Parse_Serializer
|
||||
* @package Zend_Amf
|
||||
* @subpackage Parse_Amf0
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Amf_Parse_Amf0_Serializer extends Zend_Amf_Parse_Serializer
|
||||
{
|
||||
/**
|
||||
* @var string Name of the class to be returned
|
||||
*/
|
||||
protected $_className = '';
|
||||
|
||||
/**
|
||||
* An array of reference objects
|
||||
* @var array
|
||||
*/
|
||||
protected $_referenceObjects = array();
|
||||
|
||||
/**
|
||||
* Determine type and serialize accordingly
|
||||
*
|
||||
* Checks to see if the type was declared and then either
|
||||
* auto negotiates the type or relies on the user defined markerType to
|
||||
* serialize the data into amf
|
||||
*
|
||||
* @param misc $data
|
||||
* @param misc $markerType
|
||||
* @return Zend_Amf_Parse_Amf0_Serializer
|
||||
* @throws Zend_Amf_Exception for unrecognized types or data
|
||||
*/
|
||||
public function writeTypeMarker($data, $markerType = null)
|
||||
{
|
||||
if (null !== $markerType) {
|
||||
//try to reference the given object
|
||||
if( !$this->writeObjectReference($data, $markerType) ) {
|
||||
|
||||
// Write the Type Marker to denote the following action script data type
|
||||
$this->_stream->writeByte($markerType);
|
||||
switch($markerType) {
|
||||
case Zend_Amf_Constants::AMF0_NUMBER:
|
||||
$this->_stream->writeDouble($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_BOOLEAN:
|
||||
$this->_stream->writeByte($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_STRING:
|
||||
$this->_stream->writeUTF($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_OBJECT:
|
||||
$this->writeObject($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_NULL:
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_REFERENCE:
|
||||
$this->_stream->writeInt($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_MIXEDARRAY:
|
||||
// Write length of numeric keys as zero.
|
||||
$this->_stream->writeLong(0);
|
||||
$this->writeObject($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_ARRAY:
|
||||
$this->writeArray($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_DATE:
|
||||
$this->writeDate($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_LONGSTRING:
|
||||
$this->_stream->writeLongUTF($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_TYPEDOBJECT:
|
||||
$this->writeTypedObject($data);
|
||||
break;
|
||||
case Zend_Amf_Constants::AMF0_AMF3:
|
||||
$this->writeAmf3TypeMarker($data);
|
||||
break;
|
||||
default:
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception("Unknown Type Marker: " . $markerType);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(is_resource($data)) {
|
||||
$data = Zend_Amf_Parse_TypeLoader::handleResource($data);
|
||||
}
|
||||
switch (true) {
|
||||
case (is_int($data) || is_float($data)):
|
||||
$markerType = Zend_Amf_Constants::AMF0_NUMBER;
|
||||
break;
|
||||
case (is_bool($data)):
|
||||
$markerType = Zend_Amf_Constants::AMF0_BOOLEAN;
|
||||
break;
|
||||
case (is_string($data) && (strlen($data) > 65536)):
|
||||
$markerType = Zend_Amf_Constants::AMF0_LONGSTRING;
|
||||
break;
|
||||
case (is_string($data)):
|
||||
$markerType = Zend_Amf_Constants::AMF0_STRING;
|
||||
break;
|
||||
case (is_object($data)):
|
||||
if (($data instanceof DateTime) || ($data instanceof Zend_Date)) {
|
||||
$markerType = Zend_Amf_Constants::AMF0_DATE;
|
||||
} else {
|
||||
|
||||
if($className = $this->getClassName($data)){
|
||||
//Object is a Typed object set classname
|
||||
$markerType = Zend_Amf_Constants::AMF0_TYPEDOBJECT;
|
||||
$this->_className = $className;
|
||||
} else {
|
||||
// Object is a generic classname
|
||||
$markerType = Zend_Amf_Constants::AMF0_OBJECT;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case (null === $data):
|
||||
$markerType = Zend_Amf_Constants::AMF0_NULL;
|
||||
break;
|
||||
case (is_array($data)):
|
||||
// check if it is an associative array
|
||||
$i = 0;
|
||||
foreach (array_keys($data) as $key) {
|
||||
// check if it contains non-integer keys
|
||||
if (!is_numeric($key) || intval($key) != $key) {
|
||||
$markerType = Zend_Amf_Constants::AMF0_OBJECT;
|
||||
break;
|
||||
// check if it is a sparse indexed array
|
||||
} else if ($key != $i) {
|
||||
$markerType = Zend_Amf_Constants::AMF0_MIXEDARRAY;
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
// Dealing with a standard numeric array
|
||||
if(!$markerType){
|
||||
$markerType = Zend_Amf_Constants::AMF0_ARRAY;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Unsupported data type: ' . gettype($data));
|
||||
}
|
||||
|
||||
$this->writeTypeMarker($data, $markerType);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given object is in the reference table, write the reference if it exists,
|
||||
* otherwise add the object to the reference table
|
||||
*
|
||||
* @param mixed $object object to check for reference
|
||||
* @param $markerType AMF type of the object to write
|
||||
* @return Boolean true, if the reference was written, false otherwise
|
||||
*/
|
||||
protected function writeObjectReference($object, $markerType){
|
||||
if( $markerType == Zend_Amf_Constants::AMF0_OBJECT ||
|
||||
$markerType == Zend_Amf_Constants::AMF0_MIXEDARRAY ||
|
||||
$markerType == Zend_Amf_Constants::AMF0_ARRAY ||
|
||||
$markerType == Zend_Amf_Constants::AMF0_TYPEDOBJECT ) {
|
||||
|
||||
$ref = array_search($object, $this->_referenceObjects,true);
|
||||
//handle object reference
|
||||
if($ref !== false){
|
||||
$this->writeTypeMarker($ref,Zend_Amf_Constants::AMF0_REFERENCE);
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->_referenceObjects[] = $object;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a PHP array with string or mixed keys.
|
||||
*
|
||||
* @param object $data
|
||||
* @return Zend_Amf_Parse_Amf0_Serializer
|
||||
*/
|
||||
public function writeObject($object)
|
||||
{
|
||||
// Loop each element and write the name of the property.
|
||||
foreach ($object as $key => $value) {
|
||||
// skip variables starting with an _ private transient
|
||||
if( $key[0] == "_") continue;
|
||||
$this->_stream->writeUTF($key);
|
||||
$this->writeTypeMarker($value);
|
||||
}
|
||||
|
||||
// Write the end object flag
|
||||
$this->_stream->writeInt(0);
|
||||
$this->_stream->writeByte(Zend_Amf_Constants::AMF0_OBJECTTERM);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a standard numeric array to the output stream. If a mixed array
|
||||
* is encountered call writeTypeMarker with mixed array.
|
||||
*
|
||||
* @param array $array
|
||||
* @return Zend_Amf_Parse_Amf0_Serializer
|
||||
*/
|
||||
public function writeArray($array)
|
||||
{
|
||||
$length = count($array);
|
||||
if (!$length < 0) {
|
||||
// write the length of the array
|
||||
$this->_stream->writeLong(0);
|
||||
} else {
|
||||
// Write the length of the numeric array
|
||||
$this->_stream->writeLong($length);
|
||||
for ($i=0; $i<$length; $i++) {
|
||||
$value = isset($array[$i]) ? $array[$i] : null;
|
||||
$this->writeTypeMarker($value);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the DateTime into an AMF Date
|
||||
*
|
||||
* @param DateTime|Zend_Date $data
|
||||
* @return Zend_Amf_Parse_Amf0_Serializer
|
||||
*/
|
||||
public function writeDate($data)
|
||||
{
|
||||
if ($data instanceof DateTime) {
|
||||
$dateString = $data->format('U');
|
||||
} elseif ($data instanceof Zend_Date) {
|
||||
$dateString = $data->toString('U');
|
||||
} else {
|
||||
require_once 'Zend/Amf/Exception.php';
|
||||
throw new Zend_Amf_Exception('Invalid date specified; must be a DateTime or Zend_Date object');
|
||||
}
|
||||
$dateString *= 1000;
|
||||
|
||||
// Make the conversion and remove milliseconds.
|
||||
$this->_stream->writeDouble($dateString);
|
||||
|
||||
// Flash does not respect timezone but requires it.
|
||||
$this->_stream->writeInt(0);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a class mapped object to the output stream.
|
||||
*
|
||||
* @param object $data
|
||||
* @return Zend_Amf_Parse_Amf0_Serializer
|
||||
*/
|
||||
public function writeTypedObject($data)
|
||||
{
|
||||
$this->_stream->writeUTF($this->_className);
|
||||
$this->writeObject($data);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encountered and AMF3 Type Marker use AMF3 serializer. Once AMF3 is
|
||||
* encountered it will not return to AMf0.
|
||||
*
|
||||
* @param string $data
|
||||
* @return Zend_Amf_Parse_Amf0_Serializer
|
||||
*/
|
||||
public function writeAmf3TypeMarker($data)
|
||||
{
|
||||
require_once 'Zend/Amf/Parse/Amf3/Serializer.php';
|
||||
$serializer = new Zend_Amf_Parse_Amf3_Serializer($this->_stream);
|
||||
$serializer->writeTypeMarker($data);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find if the class name is a class mapped name and return the
|
||||
* respective classname if it is.
|
||||
*
|
||||
* @param object $object
|
||||
* @return false|string $className
|
||||
*/
|
||||
protected function getClassName($object)
|
||||
{
|
||||
require_once 'Zend/Amf/Parse/TypeLoader.php';
|
||||
//Check to see if the object is a typed object and we need to change
|
||||
$className = '';
|
||||
switch (true) {
|
||||
// the return class mapped name back to actionscript class name.
|
||||
case Zend_Amf_Parse_TypeLoader::getMappedClassName(get_class($object)):
|
||||
$className = Zend_Amf_Parse_TypeLoader::getMappedClassName(get_class($object));
|
||||
break;
|
||||
// Check to see if the user has defined an explicit Action Script type.
|
||||
case isset($object->_explicitType):
|
||||
$className = $object->_explicitType;
|
||||
break;
|
||||
// Check if user has defined a method for accessing the Action Script type
|
||||
case method_exists($object, 'getASClassName'):
|
||||
$className = $object->getASClassName();
|
||||
break;
|
||||
// No return class name is set make it a generic object
|
||||
case ($object instanceof stdClass):
|
||||
$className = '';
|
||||
break;
|
||||
// By default, use object's class name
|
||||
default:
|
||||
$className = get_class($object);
|
||||
break;
|
||||
}
|
||||
if(!$className == '') {
|
||||
return $className;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue