当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Amf_Parse_TypeLoader::handleResource方法代码示例

本文整理汇总了PHP中Zend_Amf_Parse_TypeLoader::handleResource方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Amf_Parse_TypeLoader::handleResource方法的具体用法?PHP Zend_Amf_Parse_TypeLoader::handleResource怎么用?PHP Zend_Amf_Parse_TypeLoader::handleResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Amf_Parse_TypeLoader的用法示例。


在下文中一共展示了Zend_Amf_Parse_TypeLoader::handleResource方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: writeTypeMarker

 /**
  * 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  mixed $data
  * @param  mixed $markerType
  * @param  mixed $dataByVal
  * @return Zend_Amf_Parse_Amf0_Serializer
  * @throws Zend_Amf_Exception for unrecognized types or data
  */
 public function writeTypeMarker(&$data, $markerType = null, $dataByVal = false)
 {
     // Workaround for PHP5 with E_STRICT enabled complaining about "Only
     // variables should be passed by reference"
     if (null === $data && $dataByVal !== false) {
         $data =& $dataByVal;
     }
     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;
//.........这里部分代码省略.........
开发者ID:ahdail,项目名称:humhub,代码行数:101,代码来源:Serializer.php

示例2: writeTypeMarker

 public function writeTypeMarker($data, $markerType = null)
 {
     if (null !== $markerType) {
         $this->_stream->writeByte($markerType);
         switch ($markerType) {
             case Zend_Amf_Constants::AMF3_NULL:
                 break;
             case Zend_Amf_Constants::AMF3_BOOLEAN_FALSE:
                 break;
             case Zend_Amf_Constants::AMF3_BOOLEAN_TRUE:
                 break;
             case Zend_Amf_Constants::AMF3_INTEGER:
                 $this->writeInteger($data);
                 break;
             case Zend_Amf_Constants::AMF3_NUMBER:
                 $this->_stream->writeDouble($data);
                 break;
             case Zend_Amf_Constants::AMF3_STRING:
                 $this->writeString($data);
                 break;
             case Zend_Amf_Constants::AMF3_DATE:
                 $this->writeDate($data);
                 break;
             case Zend_Amf_Constants::AMF3_ARRAY:
                 $this->writeArray($data);
                 break;
             case Zend_Amf_Constants::AMF3_OBJECT:
                 $this->writeObject($data);
                 break;
             case Zend_Amf_Constants::AMF3_BYTEARRAY:
                 $this->writeByteArray($data);
                 break;
             case Zend_Amf_Constants::AMF3_XMLSTRING:
                 $this->writeXml($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 null === $data:
                 $markerType = Zend_Amf_Constants::AMF3_NULL;
                 break;
             case is_bool($data):
                 if ($data) {
                     $markerType = Zend_Amf_Constants::AMF3_BOOLEAN_TRUE;
                 } else {
                     $markerType = Zend_Amf_Constants::AMF3_BOOLEAN_FALSE;
                 }
                 break;
             case is_int($data):
                 if ($data > 0xfffffff || $data < -268435456) {
                     $markerType = Zend_Amf_Constants::AMF3_NUMBER;
                 } else {
                     $markerType = Zend_Amf_Constants::AMF3_INTEGER;
                 }
                 break;
             case is_float($data):
                 $markerType = Zend_Amf_Constants::AMF3_NUMBER;
                 break;
             case is_string($data):
                 $markerType = Zend_Amf_Constants::AMF3_STRING;
                 break;
             case is_array($data):
                 $markerType = Zend_Amf_Constants::AMF3_ARRAY;
                 break;
             case is_object($data):
                 if ($data instanceof DateTime || $data instanceof Zend_Date) {
                     $markerType = Zend_Amf_Constants::AMF3_DATE;
                 } else {
                     if ($data instanceof Zend_Amf_Value_ByteArray) {
                         $markerType = Zend_Amf_Constants::AMF3_BYTEARRAY;
                     } else {
                         if ($data instanceof DOMDocument || $data instanceof SimpleXMLElement) {
                             $markerType = Zend_Amf_Constants::AMF3_XMLSTRING;
                         } else {
                             $markerType = Zend_Amf_Constants::AMF3_OBJECT;
                         }
                     }
                 }
                 break;
             default:
                 require_once 'Zend/Amf/Exception.php';
                 throw new Zend_Amf_Exception('Unsupported data type: ' . gettype($data));
         }
         $this->writeTypeMarker($data, $markerType);
     }
 }
开发者ID:robextrem,项目名称:testgrid,代码行数:92,代码来源:Serializer.php

示例3: writeTypeMarker

 /**
  * Serialize PHP types to AMF3 and write to stream
  *
  * Checks to see if the type was declared and then either
  * auto negotiates the type or use the user defined markerType to
  * serialize the data from php back to AMF3
  *
  * @param  mixed $data
  * @param  int $markerType
  * @param  mixed $dataByVal
  * @return void
  */
 public function writeTypeMarker(&$data, $markerType = null, $dataByVal = false)
 {
     // Workaround for PHP5 with E_STRICT enabled complaining about "Only
     // variables should be passed by reference"
     if (null === $data && $dataByVal !== false) {
         $data =& $dataByVal;
     }
     if (null !== $markerType) {
         // Write the Type Marker to denote the following action script data type
         $this->_stream->writeByte($markerType);
         switch ($markerType) {
             case Zend_Amf_Constants::AMF3_NULL:
                 break;
             case Zend_Amf_Constants::AMF3_BOOLEAN_FALSE:
                 break;
             case Zend_Amf_Constants::AMF3_BOOLEAN_TRUE:
                 break;
             case Zend_Amf_Constants::AMF3_INTEGER:
                 $this->writeInteger($data);
                 break;
             case Zend_Amf_Constants::AMF3_NUMBER:
                 $this->_stream->writeDouble($data);
                 break;
             case Zend_Amf_Constants::AMF3_STRING:
                 $this->writeString($data);
                 break;
             case Zend_Amf_Constants::AMF3_DATE:
                 $this->writeDate($data);
                 break;
             case Zend_Amf_Constants::AMF3_ARRAY:
                 $this->writeArray($data);
                 break;
             case Zend_Amf_Constants::AMF3_OBJECT:
                 $this->writeObject($data);
                 break;
             case Zend_Amf_Constants::AMF3_BYTEARRAY:
                 $this->writeByteArray($data);
                 break;
             case Zend_Amf_Constants::AMF3_XMLSTRING:
                 $this->writeXml($data);
                 break;
             default:
                 require_once 'Zend/Amf/Exception.php';
                 throw new Zend_Amf_Exception('Unknown Type Marker: ' . $markerType);
         }
     } else {
         // Detect Type Marker
         if (is_resource($data)) {
             $data = Zend_Amf_Parse_TypeLoader::handleResource($data);
         }
         switch (true) {
             case null === $data:
                 $markerType = Zend_Amf_Constants::AMF3_NULL;
                 break;
             case is_bool($data):
                 if ($data) {
                     $markerType = Zend_Amf_Constants::AMF3_BOOLEAN_TRUE;
                 } else {
                     $markerType = Zend_Amf_Constants::AMF3_BOOLEAN_FALSE;
                 }
                 break;
             case is_int($data):
                 if ($data > 0xfffffff || $data < -268435456) {
                     $markerType = Zend_Amf_Constants::AMF3_NUMBER;
                 } else {
                     $markerType = Zend_Amf_Constants::AMF3_INTEGER;
                 }
                 break;
             case is_float($data):
                 $markerType = Zend_Amf_Constants::AMF3_NUMBER;
                 break;
             case is_string($data):
                 $markerType = Zend_Amf_Constants::AMF3_STRING;
                 break;
             case is_array($data):
                 $markerType = Zend_Amf_Constants::AMF3_ARRAY;
                 break;
             case is_object($data):
                 // Handle object types.
                 if ($data instanceof DateTime || $data instanceof Zend_Date) {
                     $markerType = Zend_Amf_Constants::AMF3_DATE;
                 } else {
                     if ($data instanceof Zend_Amf_Value_ByteArray) {
                         $markerType = Zend_Amf_Constants::AMF3_BYTEARRAY;
                     } else {
                         if ($data instanceof DOMDocument || $data instanceof SimpleXMLElement) {
                             $markerType = Zend_Amf_Constants::AMF3_XMLSTRING;
                         } else {
//.........这里部分代码省略.........
开发者ID:gomestai,项目名称:flextrine,代码行数:101,代码来源:Serializer.php

示例4: writeTypeMarker

    /**
     * Serialize PHP types to AMF3 and write to stream
     *
     * Checks to see if the type was declared and then either
     * auto negotiates the type or use the user defined markerType to
     * serialize the data from php back to AMF3
     *
     * @param  mixed $content
     * @param  int $markerType
     * @return void
     */
    public function writeTypeMarker($data, $markerType=null)
    {
        if (null !== $markerType) {
            // Write the Type Marker to denote the following action script data type
            $this->_stream->writeByte($markerType);

            switch ($markerType) {
                case Zend_Amf_Constants::AMF3_NULL:
                    break;
                case Zend_Amf_Constants::AMF3_BOOLEAN_FALSE:
                    break;
                case Zend_Amf_Constants::AMF3_BOOLEAN_TRUE:
                    break;
                case Zend_Amf_Constants::AMF3_INTEGER:
                    $this->writeInteger($data);
                    break;
                case Zend_Amf_Constants::AMF3_NUMBER:
                    $this->_stream->writeDouble($data);
                    break;
                case Zend_Amf_Constants::AMF3_STRING:
                    $this->writeString($data);
                    break;
                case Zend_Amf_Constants::AMF3_DATE:
                    $this->writeDate($data);
                    break;
                case Zend_Amf_Constants::AMF3_ARRAY:
                    $this->writeArray($data);
                    break;
                case Zend_Amf_Constants::AMF3_OBJECT:
                    $this->writeObject($data);
                    break;
                case Zend_Amf_Constants::AMF3_BYTEARRAY:
                    $this->writeString($data instanceof Zend_Amf_Value_ByteArray ? $data->getData() : $data);
                    break;
                case Zend_Amf_Constants::AMF3_XMLSTRING;
                    $this->writeString($data);
                    break;
                default:
                    require_once 'Zend/Amf/Exception.php';
                    throw new Zend_Amf_Exception('Unknown Type Marker: ' . $markerType);
            }
        } else {
            // Detect Type Marker
            if(is_resource($data)) {
                $data = Zend_Amf_Parse_TypeLoader::handleResource($data);
            }
             switch (true) {
             	case (null === $data):
                    $markerType = Zend_Amf_Constants::AMF3_NULL;
                    break;
                case (is_bool($data)):
                    if ($data){
                        $markerType = Zend_Amf_Constants::AMF3_BOOLEAN_TRUE;
                    } else {
                        $markerType = Zend_Amf_Constants::AMF3_BOOLEAN_FALSE;
                    }
                    break;
                case (is_int($data)):
                    if (($data > 0xFFFFFFF) || ($data < -268435456)) {
                        $markerType = Zend_Amf_Constants::AMF3_NUMBER;
                    } else {
                        $markerType = Zend_Amf_Constants::AMF3_INTEGER;
                    }
                    break;
                case (is_float($data)):
                    $markerType = Zend_Amf_Constants::AMF3_NUMBER;
                    break;
                case (is_string($data)):
                    $markerType = Zend_Amf_Constants::AMF3_STRING;
                    break;
                case (is_array($data)):
                    $markerType = Zend_Amf_Constants::AMF3_ARRAY;
                    break;
                case (is_object($data)):
                    // Handle object types.
                    if (($data instanceof DateTime) || ($data instanceof Zend_Date)) {
                        $markerType = Zend_Amf_Constants::AMF3_DATE;
                    } else if ($data instanceof Zend_Amf_Value_ByteArray) {
                        $markerType = Zend_Amf_Constants::AMF3_BYTEARRAY;
                    } else if ($data instanceof DOMDocument) {
                        // convert object to string
                        $data = $data->saveXml();
                        $markerType = Zend_Amf_Constants::AMF3_XMLSTRING;
                    } else if ($data instanceof SimpleXMLElement) {
                        // convert object to string;
                        $data = $data->asXML();
                        $markerType = Zend_Amf_Constants::AMF3_XMLSTRING;
                    } else {
                        $markerType = Zend_Amf_Constants::AMF3_OBJECT;
//.........这里部分代码省略.........
开发者ID:BGCX262,项目名称:zym-svn-to-git,代码行数:101,代码来源:Serializer.php


注:本文中的Zend_Amf_Parse_TypeLoader::handleResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。