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


PHP Zend_Amf_Parse_TypeLoader::loadType方法代码示例

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


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

示例1: readTypedObject

 /**
  * 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 PHP_LIBRARY_PATH . '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;
 }
开发者ID:netixx,项目名称:Stock,代码行数:27,代码来源:Deserializer.php

示例2: readObject

 /**
  * 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()
 {
     $traitsInfo = $this->readInteger();
     $storedObject = ($traitsInfo & 0x1) == 0;
     $traitsInfo = $traitsInfo >> 1;
     // Check if the Object is in the stored Objects reference table
     if ($storedObject) {
         $ref = $traitsInfo;
         if (!isset($this->_referenceObjects[$ref])) {
             require_once 'Zend/Amf/Exception.php';
             throw new Zend_Amf_Exception('Unknown Object reference: ' . $ref);
         }
         $returnObject = $this->_referenceObjects[$ref];
     } else {
         // Check if the Object is in the stored Definistions reference table
         $storedClass = ($traitsInfo & 0x1) == 0;
         $traitsInfo = $traitsInfo >> 1;
         if ($storedClass) {
             $ref = $traitsInfo;
             if (!isset($this->_referenceDefinitions[$ref])) {
                 require_once 'Zend/Amf/Exception.php';
                 throw new Zend_Amf_Exception('Unknows Definition reference: ' . $ref);
             }
             // Populate the reference attributes
             $className = $this->_referenceDefinitions[$ref]['className'];
             $encoding = $this->_referenceDefinitions[$ref]['encoding'];
             $propertyNames = $this->_referenceDefinitions[$ref]['propertyNames'];
         } else {
             // The class was not in the reference tables. Start reading rawdata to build traits.
             // Create a traits table. Zend_Amf_Value_TraitsInfo would be ideal
             $className = $this->readString();
             $encoding = $traitsInfo & 0x3;
             $propertyNames = array();
             $traitsInfo = $traitsInfo >> 2;
         }
         // We now have the object traits defined in variables. Time to go to work:
         if (!$className) {
             // No class name generic object
             $returnObject = new stdClass();
         } else {
             // Defined object
             // Typed object lookup agsinst registered classname maps
             if ($loader = Zend_Amf_Parse_TypeLoader::loadType($className)) {
                 $returnObject = new $loader();
             } else {
                 //user defined typed object
                 require_once 'Zend/Amf/Exception.php';
                 throw new Zend_Amf_Exception('Typed object not found: ' . $className . ' ');
             }
         }
         // Add the Object ot the reference table
         $this->_referenceObjects[] = $returnObject;
         $properties = array();
         // clear value
         // Check encoding types for additional processing.
         switch ($encoding) {
             case Zend_Amf_Constants::ET_EXTERNAL:
                 // Externalizable object such as {ArrayCollection} and {ObjectProxy}
                 if (!$storedClass) {
                     $this->_referenceDefinitions[] = array('className' => $className, 'encoding' => $encoding, 'propertyNames' => $propertyNames);
                 }
                 $returnObject->externalizedData = $this->readTypeMarker();
                 break;
             case Zend_Amf_Constants::ET_DYNAMIC:
                 // used for Name-value encoding
                 if (!$storedClass) {
                     $this->_referenceDefinitions[] = array('className' => $className, 'encoding' => $encoding, 'propertyNames' => $propertyNames);
                 }
                 // not a refrence object read name value properties from byte stream
                 do {
                     $property = $this->readString();
                     if ($property != "") {
                         $propertyNames[] = $property;
                         $properties[$property] = $this->readTypeMarker();
                     }
                 } while ($property != "");
                 break;
             default:
                 // basic property list object.
                 if (!$storedClass) {
                     $count = $traitsInfo;
                     // Number of properties in the list
                     for ($i = 0; $i < $count; $i++) {
                         $propertyNames[] = $this->readString();
                     }
                     // Add a refrence to the class.
                     $this->_referenceDefinitions[] = array('className' => $className, 'encoding' => $encoding, 'propertyNames' => $propertyNames);
                 }
                 foreach ($propertyNames as $property) {
                     $properties[$property] = $this->readTypeMarker();
                 }
                 break;
         }
         // Add properties back to the return object.
//.........这里部分代码省略.........
开发者ID:sonicmaster,项目名称:RPG,代码行数:101,代码来源:Deserializer.php

示例3: testUnknownClassMap

 public function testUnknownClassMap()
 {
     $class = Zend_Amf_Parse_TypeLoader::loadType('com.example.vo.Bogus');
     $this->assertEquals('stdClass', $class);
 }
开发者ID:travisj,项目名称:zf,代码行数:5,代码来源:TypeLoaderTest.php

示例4: readTypedObject

 /**
  * 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
  * @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;
         }
     }
     return $returnObject;
 }
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:24,代码来源:Deserializer.php

示例5: readObject

 public function readObject()
 {
     $traitsInfo = $this->readInteger();
     $storedObject = ($traitsInfo & 0x1) == 0;
     $traitsInfo = $traitsInfo >> 1;
     if ($storedObject) {
         $ref = $traitsInfo;
         if (!isset($this->_referenceObjects[$ref])) {
             require_once 'Zend/Amf/Exception.php';
             throw new Zend_Amf_Exception('Unknown Object reference: ' . $ref);
         }
         $returnObject = $this->_referenceObjects[$ref];
     } else {
         $storedClass = ($traitsInfo & 0x1) == 0;
         $traitsInfo = $traitsInfo >> 1;
         if ($storedClass) {
             $ref = $traitsInfo;
             if (!isset($this->_referenceDefinitions[$ref])) {
                 require_once 'Zend/Amf/Exception.php';
                 throw new Zend_Amf_Exception('Unknows Definition reference: ' . $ref);
             }
             $className = $this->_referenceDefinitions[$ref]['className'];
             $encoding = $this->_referenceDefinitions[$ref]['encoding'];
             $propertyNames = $this->_referenceDefinitions[$ref]['propertyNames'];
         } else {
             $className = $this->readString();
             $encoding = $traitsInfo & 0x3;
             $propertyNames = array();
             $traitsInfo = $traitsInfo >> 2;
         }
         if (!$className) {
             $returnObject = new stdClass();
         } else {
             if ($loader = Zend_Amf_Parse_TypeLoader::loadType($className)) {
                 $returnObject = new $loader();
             } else {
                 require_once 'Zend/Amf/Exception.php';
                 throw new Zend_Amf_Exception('Typed object not found: ' . $className . ' ');
             }
         }
         $this->_referenceObjects[] = $returnObject;
         $properties = array();
         switch ($encoding) {
             case Zend_Amf_Constants::ET_EXTERNAL:
                 if (!$storedClass) {
                     $this->_referenceDefinitions[] = array('className' => $className, 'encoding' => $encoding, 'propertyNames' => $propertyNames);
                 }
                 $returnObject->externalizedData = $this->readTypeMarker();
                 break;
             case Zend_Amf_Constants::ET_DYNAMIC:
                 if (!$storedClass) {
                     $this->_referenceDefinitions[] = array('className' => $className, 'encoding' => $encoding, 'propertyNames' => $propertyNames);
                 }
                 do {
                     $property = $this->readString();
                     if ($property != "") {
                         $propertyNames[] = $property;
                         $properties[$property] = $this->readTypeMarker();
                     }
                 } while ($property != "");
                 break;
             default:
                 if (!$storedClass) {
                     $count = $traitsInfo;
                     for ($i = 0; $i < $count; $i++) {
                         $propertyNames[] = $this->readString();
                     }
                     $this->_referenceDefinitions[] = array('className' => $className, 'encoding' => $encoding, 'propertyNames' => $propertyNames);
                 }
                 foreach ($propertyNames as $property) {
                     $properties[$property] = $this->readTypeMarker();
                 }
                 break;
         }
         foreach ($properties as $key => $value) {
             if ($key) {
                 $returnObject->{$key} = $value;
             }
         }
     }
     if ($returnObject instanceof Zend_Amf_Value_Messaging_ArrayCollection) {
         if (isset($returnObject->externalizedData)) {
             $returnObject = $returnObject->externalizedData;
         } else {
             $returnObject = get_object_vars($returnObject);
         }
     }
     return $returnObject;
 }
开发者ID:robextrem,项目名称:testgrid,代码行数:89,代码来源:Deserializer.php


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