本文整理汇总了PHP中Zend_Amf_Parse_TypeLoader类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Amf_Parse_TypeLoader类的具体用法?PHP Zend_Amf_Parse_TypeLoader怎么用?PHP Zend_Amf_Parse_TypeLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Amf_Parse_TypeLoader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
$this->_server = new Zend_Amf_Server();
$this->_server->setProduction(false);
Zend_Amf_Parse_TypeLoader::resetMap();
$this->_acl = new Zend_Acl();
}
开发者ID:jsnshrmn,项目名称:Suma,代码行数:7,代码来源:AuthTest.php
示例2: setClassMap
/**
* Map ActionScript classes to PHP classes
*
* @param string $asClass
* @param string $phpClass
* @return Zend_Amf_Server
*/
public function setClassMap($asClass, $phpClass)
{
require_once 'Zend/Amf/Parse/TypeLoader.php';
Zend_Amf_Parse_TypeLoader::setMapping($asClass, $phpClass);
return $this;
}
开发者ID:raffpaquin,项目名称:Gregory,代码行数:13,代码来源:Server.php
示例3: _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_Parse_TypeLoader::getMappedClassName($typename))) {
return $asname;
}
return $typename;
}
开发者ID:robeendey,项目名称:ce,代码行数:19,代码来源:Introspector.php
示例4: testClassMap
/**
* Add a class mapping and lookup the mapping to make sure
* the mapping succeeds
*/
public function testClassMap()
{
$this->_server->setClassMap('controller.test', 'Zend_Amf_testclass');
$className = Zend_Amf_Parse_TypeLoader::getMappedClassName('Zend_Amf_testclass');
$this->assertEquals('controller.test', $className);
}
开发者ID:nbcutech,项目名称:o3drupal,代码行数:10,代码来源:ServerTest.php
示例5: writeObject
public function writeObject($object)
{
if ($this->writeObjectReference($object)) {
return $this;
}
$className = '';
switch (true) {
case $className = Zend_Amf_Parse_TypeLoader::getMappedClassName(get_class($object)):
break;
case isset($object->_explicitType):
$className = $object->_explicitType;
break;
case method_exists($object, 'getASClassName'):
$className = $object->getASClassName();
break;
case $object instanceof stdClass:
$className = '';
break;
default:
$className = get_class($object);
break;
}
$writeTraits = true;
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 == '') {
$encoding = Zend_Amf_Constants::ET_DYNAMIC;
} else {
$encoding = Zend_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 = Zend_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 Zend_Amf_Constants::ET_PROPLIST:
foreach ($propertyNames as $key) {
$this->writeTypeMarker($object->{$key});
}
break;
case Zend_Amf_Constants::ET_DYNAMIC:
foreach ($propertyNames as $key) {
$this->writeTypeMarker($object->{$key});
}
foreach ($object as $key => $value) {
if (!in_array($key, $propertyNames) && $key[0] != "_") {
$this->writeString($key);
$this->writeTypeMarker($value);
}
}
$this->writeString('');
break;
case Zend_Amf_Constants::ET_EXTERNAL:
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('External Object Encoding not implemented');
break;
default:
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Unknown Object Encoding type: ' . $encoding);
}
} catch (Exception $e) {
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Unable to writeObject output: ' . $e->getMessage(), 0, $e);
}
return $this;
}
开发者ID:robextrem,项目名称:testgrid,代码行数:86,代码来源:Serializer.php
示例6: 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
示例7: setClassMap
/**
* Map ActionScript classes to PHP classes
*
* @param string $asClass
* @param string $phpClass
* @return Zend_Amf_Server
*/
public function setClassMap($asClass, $phpClass)
{
Zend_Amf_Parse_TypeLoader::setMapping($asClass, $phpClass);
return $this;
}
开发者ID:NerdGZ,项目名称:icingaweb2,代码行数:12,代码来源:Server.php
示例8: testAmf0TypedObjecDeserializedToNativePHPObject
public function testAmf0TypedObjecDeserializedToNativePHPObject()
{
Zend_Amf_Parse_TypeLoader::setMapping("ContactVO", "Contact");
$myRequest = file_get_contents(dirname(__FILE__) . '/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 Zend_Amf_Value_MessageBody);
$data = $bodies[0]->getData();
// Make sure that we are dealing with a PHP simpleXml element
$this->assertTrue($data[0] instanceof Contact);
// Make sure that the xml was deserialized properly and check its value
$this->assertEquals('arnold', (string) $data[0]->lastname);
}
开发者ID:omusico,项目名称:logica,代码行数:18,代码来源:RequestTest.php
示例9: testUnknownClassMap
public function testUnknownClassMap()
{
$class = Zend_Amf_Parse_TypeLoader::loadType('com.example.vo.Bogus');
$this->assertEquals('stdClass', $class);
}
开发者ID:travisj,项目名称:zf,代码行数:5,代码来源:TypeLoaderTest.php
示例10: writeObject
/**
* Write object to ouput stream
*
* @param mixed $data
* @return Zend_Amf_Parse_Amf3_Serializer
*/
public function writeObject($object)
{
$encoding = Zend_Amf_Constants::ET_PROPLIST;
$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 = Zend_Amf_Parse_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
default:
break;
}
$traitsInfo = Zend_Amf_Constants::AMF3_OBJECT_ENCODING;
$traitsInfo |= $encoding << 2;
try {
switch ($encoding) {
case Zend_Amf_Constants::ET_PROPLIST:
$count = 0;
foreach ($object as $key => $value) {
if ($key[0] != "_") {
$count++;
}
}
$traitsInfo |= $count << 4;
// Write the object ID
$this->writeInteger($traitsInfo);
// Write the classname
$this->writeString($className);
// Write the object Key's to the output stream
foreach ($object as $key => $value) {
if ($key[0] != "_") {
$this->writeString($key);
}
}
//Write the object values to the output stream.
foreach ($object as $key => $value) {
if ($key[0] != "_") {
$this->writeTypeMarker($value);
}
}
break;
case Zend_Amf_Constants::ET_EXTERNAL:
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('External Object Encoding not implemented');
break;
default:
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Unknown Object Encoding type: ' . $encoding);
}
} catch (Exception $e) {
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Unable to writeObject output: ' . $e->getMessage());
}
return $this;
}
开发者ID:anunay,项目名称:stentors,代码行数:73,代码来源:Serializer.php
示例11: testCtxNoParse
/**
* Defining new unknown resource type, handler has no parse()
*
*/
public function testCtxNoParse()
{
Zend_Amf_Parse_TypeLoader::setResourceLoader(new Zend_Amf_TestResourceLoader("3"));
try {
$resp = $this->_callService("returnCtx");
} catch (Zend_Amf_Server_Exception $e) {
$this->assertContains("Could not call parse()", $e->getMessage());
return;
}
$this->fail("Failed to throw exception on unknown resource");
}
开发者ID:omusico,项目名称:logica,代码行数:15,代码来源:ResourceTest.php
示例12: 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
示例13: writeObject
/**
* Write object to ouput stream
*
* @param mixed $data
* @return Zend_Amf_Parse_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 = Zend_Amf_Parse_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 = Zend_Amf_Constants::ET_DYNAMIC;
} else {
$encoding = Zend_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 = Zend_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 Zend_Amf_Constants::ET_PROPLIST:
//Write the sealed values to the output stream.
foreach ($propertyNames as $key) {
$this->writeTypeMarker($object->{$key});
}
break;
case Zend_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 Zend_Amf_Constants::ET_EXTERNAL:
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('External Object Encoding not implemented');
break;
default:
require_once 'Zend/Amf/Exception.php';
//.........这里部分代码省略.........
开发者ID:gomestai,项目名称:flextrine,代码行数:101,代码来源:Serializer.php
示例14: testPhpObjectSerializedToAmf0TypedObjectClassMap
public function testPhpObjectSerializedToAmf0TypedObjectClassMap()
{
Zend_Amf_Parse_TypeLoader::setMapping("ContactVO", "Contact");
$data = array();
$contact = new Contact();
$contact->id = '15';
$contact->firstname = 'Joe';
$contact->lastname = 'Smith';
$contact->email = '[email protected]';
$contact->mobile = '123-456-7890';
unset($contact->_explicitType);
array_push($data, $contact);
$contact = new Contact();
$contact->id = '23';
$contact->firstname = 'Adobe';
$contact->lastname = 'Flex';
$contact->email = '[email protected]';
$contact->mobile = '123-456-7890';
unset($contact->_explicitType);
array_push($data, $contact);
$newBody = new Zend_Amf_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(dirname(__FILE__) . '/Response/mock/typedObjectAmf0Response.bin');
// Check that the response matches the expected serialized value
$this->assertEquals($mockResponse, $testResponse);
}
开发者ID:travisj,项目名称:zf,代码行数:30,代码来源:ResponseTest.php
示例15: 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
示例16: 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
示例17: 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)
{
// // 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.
// 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;
}
if (!$className == '') {
return $className;
} else {
return false;
}
}
开发者ID:ahdail,项目名称:humhub,代码行数:44,代码来源:Serializer.php
示例18: _dispatch
/**
* Loads a remote class or method and executes the function and returns the result
* @param {string} $method Is the method to execute
* @param {mixed} $param values for the method
* @return {mixed} $response the result of executing the method
* @throws Zend_Amf_Server_Exception
*/
protected function _dispatch($method, $params = null, $source = null)
{
if ($source) {
if (($mapped = Zend_Amf_Parse_TypeLoader::getMappedClassName($source)) !== false) {
$source = $mapped;
}
}
$qualifiedName = empty($source) ? $method : $source . '.' . $method;
if (!isset($this->_table[$qualifiedName])) {
// if source is null a method that was not defined was called.
if ($source) {
$className = 'CodeBank' . str_replace('.', '_', $source);
if (class_exists($className, false) && !isset($this->_classAllowed[$className])) {
require_once 'Zend/Amf/Server/Exception.php';
throw new Zend_Amf_Server_Exception('Can not call "' . $className . '" - use setClass()');
}
try {
$this->getLoader()->load($className);
} catch (Exception $e) {
require_once 'Zend/Amf/Server/Exception.php';
throw new Zend_Amf_Server_Exception('Class "' . $className . '" does not exist: ' . $e->getMessage(), 0, $e);
}
// Add the new loaded class to the server.
$this->setClass($className, $source);
}
if (!isset($this->_table[$qualifiedName])) {
// Source is null or doesn't contain specified method
require_once 'Zend/Amf/Server/Exception.php';
throw new Zend_Amf_Server_Exception('Method "' . $method . '" does not exist');
}
}
$info = $this->_table[$qualifiedName];
$argv = $info->getInvokeArguments();
if (0 < count($argv)) {
$params = array_merge($params, $argv);
}
if ($info instanceof Zend_Server_Reflection_Function) {
$func = $info->getName();
$this->_checkAcl(null, $func);
$return = call_user_func_array($func, $params);
} else {
if ($info instanceof Zend_Server_Reflection_Method) {
// Get class
$class = $info->getDeclaringClass()->getName();
//Check permissions
if ($this->_canAccess($class) == false) {
$response = CodeBank_ClientAPI::responseBase();
$response['status'] = 'EROR';
$response['message'] = _t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
return $response;
}
if ('static' == $info->isStatic()) {
// for some reason, invokeArgs() does not work the same as
// invoke(), and expects the first argument to be an object.
// So, using a callback if the method is static.
$this->_checkAcl($class, $info->getName());
$return = call_user_func_array(array($class, $info->getName()), $params);
} else {
// Object methods
try {
$object = $info->getDeclaringClass()->newInstance();
} catch (Exception $e) {
throw new Zend_Amf_Server_Exception('Error instantiating class ' . $class . ' to invoke method ' . $info->getName() . ': ' . $e->getMessage(), 621, $e);
}
$this->_checkAcl($object, $info->getName());
$return = $info->invokeArgs($object, $params);
}
} else {
throw new Zend_Amf_Server_Exception('Method missing implementation ' . get_class($info));
}
}
return $return;
}
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-codebank,代码行数:80,代码来源:CodeBankAMFServer.php
示例19: setResourceLoader
/**
* Set loader for resource type handlers
*
* @param Zend_Loader_PluginLoader_Interface $loader
*/
public static function setResourceLoader(Zend_Loader_PluginLoader_Interface $loader)
{
self::$_resourceLoader = $loader;
}
开发者ID:c12g,项目名称:stratos-php,代码行数:9,代码来源:TypeLoader.php
示例20: resetMap
/**
* Reset type map
*
* @return void
*/
public static function resetMap()
{
self::$classMap = self::$_defaultClassMap;
}
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:9,代码来源:TypeLoader.php
注:本文中的Zend_Amf_Parse_TypeLoader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论