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


PHP Parser\TypeLoader类代码示例

本文整理汇总了PHP中Zend\Amf\Parser\TypeLoader的典型用法代码示例。如果您正苦于以下问题:PHP TypeLoader类的具体用法?PHP TypeLoader怎么用?PHP TypeLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setUp

 public function setUp()
 {
     $this->_server = new AMF\Server();
     $this->_server->setProduction(false);
     \Zend\AMF\Parser\TypeLoader::resetMap();
     $this->_acl = new Acl\Acl();
 }
开发者ID:stunti,项目名称:zf2,代码行数:7,代码来源:AuthTest.php

示例2: __construct

 /**
  * Constructor
  *
  * @param EventDispatcherInterface    $dispatcher An EventDispatcherInterface instance
  * @param ContainerInterface          $container  A ContainerInterface instance
  * @param ControllerResolverInterface $resolver   A ControllerResolverInterface instance
  * @param Boolean                     $debug      Debug mode
  * @param array                       $mappings   An array of mapped classes
  */
 public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ServiceResolverInterface $resolver, $debug = false, array $mappings = array())
 {
     $this->dispatcher = $dispatcher;
     $this->container = $container;
     $this->resolver = $resolver;
     $this->debug = $debug;
     foreach ($mappings as $alias => $mapping) {
         TypeLoader::setMapping($alias, $mapping['class']);
     }
 }
开发者ID:rodchyn,项目名称:AMFBundle,代码行数:19,代码来源:Server.php

示例3: testCtxNoParse

 /**
  * Defining new unknown resource type, handler has no parse()
  *
  */
 public function testCtxNoParse()
 {
     Parser\TypeLoader::setResourceLoader(new TestAsset\TestResourceLoader("3"));
     $this->setExpectedException('Zend\\AMF\\Exception', 'Could not call parse()');
     $resp = $this->_callService("returnCtx");
 }
开发者ID:stunti,项目名称:zf2,代码行数:10,代码来源:ResourceTest.php

示例4: getClassName

 /**
  * 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)
 {
     //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 Parser\TypeLoader::getMappedClassName(get_class($object)):
             $className = Parser\TypeLoader::getMappedClassName(get_class($object));
             break;
             // Check to see if the user has defined an explicit Action Script type.
             // Check to see if the user has defined an explicit Action Script type.
         // Check to see if the user has defined an explicit Action Script type.
         // 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
             // Check if user has defined a method for accessing the Action Script type
         // Check if user has defined a method for accessing the Action Script type
         // 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
             // No return class name is set make it a generic object
         // No return class name is set make it a generic object
         // No return class name is set make it a generic object
         case $object instanceof \stdClass:
             $className = '';
             break;
             // By default, use object's class name
             // By default, use object's class name
         // By default, use object's class name
         // By default, use object's class name
         default:
             $className = get_class($object);
             break;
     }
     if (!$className == '') {
         return $className;
     } else {
         return false;
     }
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:51,代码来源:Serializer.php

示例5: testCtxNoParse

 /**
  * Defining new unknown resource type, handler has no parse()
  *
  */
 public function testCtxNoParse()
 {
     $this->markTestSkipped('Plugin loader implementation needs to be revisited');
     Parser\TypeLoader::setResourceLoader(new TestAsset\TestResourceLoader("3"));
     $this->setExpectedException('Zend\\Amf\\Exception\\RuntimeException', 'Could not call parse()');
     $resp = $this->_callService("returnCtx");
 }
开发者ID:robertodormepoco,项目名称:zf2,代码行数:11,代码来源:ResourceTest.php

示例6: testClassMap

 /**
  * Add a class mapping and lookup the mapping to make sure
  * the mapping succeeds
  */
 public function testClassMap()
 {
     $this->_server->setClassMap('controller.test', 'ZendTest\\Amf\\TestAsset\\Server\\testclass');
     $className = Parser\TypeLoader::getMappedClassName('ZendTest\\Amf\\TestAsset\\Server\\testclass');
     $this->assertEquals('controller.test', $className);
 }
开发者ID:alab1001101,项目名称:zf2,代码行数:10,代码来源:ServerTest.php

示例7: testPhpObjectSerializedToAmf0TypedObjectClassMap

 public function testPhpObjectSerializedToAmf0TypedObjectClassMap()
 {
     Parser\TypeLoader::setMapping("ContactVO", "Contact");
     $data = array();
     $contact = new TestAsset\Contact();
     $contact->id = '15';
     $contact->firstname = 'Joe';
     $contact->lastname = 'Smith';
     $contact->email = 'jsmith@adobe.com';
     $contact->mobile = '123-456-7890';
     unset($contact->_explicitType);
     array_push($data, $contact);
     $contact = new TestAsset\Contact();
     $contact->id = '23';
     $contact->firstname = 'Adobe';
     $contact->lastname = 'Flex';
     $contact->email = 'was@here.com';
     $contact->mobile = '123-456-7890';
     unset($contact->_explicitType);
     array_push($data, $contact);
     $newBody = new Value\MessageBody('/1/onResult', null, $data);
     $this->_response->setObjectEncoding(0x0);
     $this->_response->addAmfBody($newBody);
     $this->_response->finalize();
     $testResponse = $this->_response->getResponse();
     // Load the expected response.
     $mockResponse = file_get_contents(__DIR__ . '/TestAsset/Response/typedObjectAmf0Response.bin');
     // Check that the response matches the expected serialized value
     $this->assertEquals($mockResponse, $testResponse);
 }
开发者ID:stunti,项目名称:zf2,代码行数:30,代码来源:ResponseTest.php

示例8: _phpTypeToAS

 /**
  * Map from PHP type name to AS type name
  *
  * @param  string $typename PHP type name
  * @return string AS type name
  */
 protected function _phpTypeToAS($typename)
 {
     if (class_exists($typename)) {
         $vars = get_class_vars($typename);
         if (isset($vars['_explicitType'])) {
             return $vars['_explicitType'];
         }
     }
     if (false !== ($asname = \Zend\Amf\Parser\TypeLoader::getMappedClassName($typename))) {
         return $asname;
     }
     return $typename;
 }
开发者ID:nevvermind,项目名称:zf2,代码行数:19,代码来源:Introspector.php

示例9: testAmf0TypedObjecDeserializedToNativePHPObject

 public function testAmf0TypedObjecDeserializedToNativePHPObject()
 {
     Parser\TypeLoader::setMapping("ContactVO", "ZendTest\\AMF\\TestAsset\\Contact");
     $myRequest = file_get_contents(__DIR__ . '/TestAsset/Request/mock/typedObjectAmf0Request.bin');
     // send the mock object request to be deserialized
     $this->_request->initialize($myRequest);
     // Make sure that no headers where recieved
     $this->assertEquals(0, sizeof($this->_request->getAmfHeaders()));
     // Make sure that the message body was set after deserialization
     $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
     $bodies = $this->_request->getAmfBodies();
     $this->assertTrue($bodies[0] instanceof Value\MessageBody);
     $data = $bodies[0]->getData();
     // Make sure that we are dealing with a PHP simpleXml element
     $this->assertTrue($data[0] instanceof TestAsset\Contact);
     // Make sure that the xml was deserialized properly and check its value
     $this->assertEquals('arnold', (string) $data[0]->lastname);
 }
开发者ID:stunti,项目名称:zf2,代码行数:18,代码来源:RequestTest.php

示例10: 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()
 {
     // get the remote class name
     $className = $this->_stream->readUTF();
     $loader = Amf\Parser\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 Amf\Value\Messaging\ArrayCollection) {
         $returnObject = get_object_vars($returnObject);
     }
     return $returnObject;
 }
开发者ID:rexmac,项目名称:zf2,代码行数:26,代码来源:Deserializer.php

示例11: setClassMap

 /**
  * Map ActionScript classes to PHP classes
  *
  * @param  string $asClass
  * @param  string $phpClass
  * @return Server
  */
 public function setClassMap($asClass, $phpClass)
 {
     Parser\TypeLoader::setMapping($asClass, $phpClass);
     return $this;
 }
开发者ID:necrogami,项目名称:zf2,代码行数:12,代码来源:Server.php

示例12: 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])) {
             throw new Parser\Exception\OutOfBoundsException('Unknown Object reference: ' . $ref);
         }
         $returnObject = $this->_referenceObjects[$ref];
     } else {
         // Check if the Object is in the stored Definitions reference table
         $storedClass = ($traitsInfo & 0x1) == 0;
         $traitsInfo = $traitsInfo >> 1;
         if ($storedClass) {
             $ref = $traitsInfo;
             if (!isset($this->_referenceDefinitions[$ref])) {
                 throw new Parser\Exception\OutOfBoundsException('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 against registered classname maps
             if ($loader = Amf\Parser\TypeLoader::loadType($className)) {
                 $returnObject = new $loader();
             } else {
                 //user defined typed object
                 throw new Parser\Exception\OutOfBoundsException('Typed object not found: ' . $className . ' ');
             }
         }
         // Add the Object to the reference table
         $this->_referenceObjects[] = $returnObject;
         $properties = array();
         // clear value
         // Check encoding types for additional processing.
         switch ($encoding) {
             case 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 Amf\Constants::ET_DYNAMIC:
                 // used for Name-value encoding
                 if (!$storedClass) {
                     $this->_referenceDefinitions[] = array('className' => $className, 'encoding' => $encoding, 'propertyNames' => $propertyNames);
                 }
                 // not a reference 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 reference 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.
         if (!is_array($properties)) {
             $properties = array();
         }
//.........这里部分代码省略.........
开发者ID:brikou,项目名称:zend_amf,代码行数:101,代码来源:Deserializer.php

示例13: testUnknownClassMap

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

示例14: writeObject

 /**
  * Write object to ouput stream
  *
  * @param  mixed $data
  * @return Zend\Amf\Parser\Amf3\Serializer
  */
 public function writeObject($object)
 {
     if ($this->writeObjectReference($object)) {
         return $this;
     }
     $className = '';
     //Check to see if the object is a typed object and we need to change
     switch (true) {
         // the return class mapped name back to actionscript class name.
         case $className = Parser\TypeLoader::getMappedClassName(get_class($object)):
             break;
             // Check to see if the user has defined an explicit Action Script type.
         // 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
         // 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
         // No return class name is set make it a generic object
         case $object instanceof \stdClass:
             $className = '';
             break;
             // By default, use object's class name
         // By default, use object's class name
         default:
             $className = get_class($object);
             break;
     }
     $writeTraits = true;
     //check to see, if we have a corresponding definition
     if (array_key_exists($className, $this->_referenceDefinitions)) {
         $traitsInfo = $this->_referenceDefinitions[$className]['id'];
         $encoding = $this->_referenceDefinitions[$className]['encoding'];
         $propertyNames = $this->_referenceDefinitions[$className]['propertyNames'];
         $traitsInfo = $traitsInfo << 2 | 0x1;
         $writeTraits = false;
     } else {
         $propertyNames = array();
         if ($className == '') {
             //if there is no className, we interpret the class as dynamic without any sealed members
             $encoding = Amf\Constants::ET_DYNAMIC;
         } else {
             $encoding = Amf\Constants::ET_PROPLIST;
             foreach ($object as $key => $value) {
                 if ($key[0] != "_") {
                     $propertyNames[] = $key;
                 }
             }
         }
         $this->_referenceDefinitions[$className] = array('id' => count($this->_referenceDefinitions), 'encoding' => $encoding, 'propertyNames' => $propertyNames);
         $traitsInfo = Amf\Constants::AMF3_OBJECT_ENCODING;
         $traitsInfo |= $encoding << 2;
         $traitsInfo |= count($propertyNames) << 4;
     }
     $this->writeInteger($traitsInfo);
     if ($writeTraits) {
         $this->writeString($className);
         foreach ($propertyNames as $value) {
             $this->writeString($value);
         }
     }
     try {
         switch ($encoding) {
             case Amf\Constants::ET_PROPLIST:
                 //Write the sealed values to the output stream.
                 foreach ($propertyNames as $key) {
                     $this->writeTypeMarker($object->{$key});
                 }
                 break;
             case Amf\Constants::ET_DYNAMIC:
                 //Write the sealed values to the output stream.
                 foreach ($propertyNames as $key) {
                     $this->writeTypeMarker($object->{$key});
                 }
                 //Write remaining properties
                 foreach ($object as $key => $value) {
                     if (!in_array($key, $propertyNames) && $key[0] != "_") {
                         $this->writeString($key);
                         $this->writeTypeMarker($value);
                     }
                 }
                 //Write an empty string to end the dynamic part
                 $this->writeString($this->_strEmpty);
                 break;
             case Amf\Constants::ET_EXTERNAL:
                 throw new Parser\Exception\OutOfBoundsException('External Object Encoding not implemented');
                 break;
             default:
                 throw new Parser\Exception\OutOfBoundsException('Unknown Object Encoding type: ' . $encoding);
         }
//.........这里部分代码省略.........
开发者ID:rexmac,项目名称:zf2,代码行数:101,代码来源:Serializer.php


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