本文整理汇总了PHP中RPC::encodeResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP RPC::encodeResponse方法的具体用法?PHP RPC::encodeResponse怎么用?PHP RPC::encodeResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RPC
的用法示例。
在下文中一共展示了RPC::encodeResponse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: encodeResponseForFailure
/**
* Returns a string that encodes an exception. If method is not
* <code>null</code>, it is an error if the exception is not in the
* method's list of checked exceptions.
*
* <p>
* If the serializationPolicy parameter is not <code>null</code>, it is
* used to determine what types can be encoded as part of this response. If
* this parameter is <code>null</code>, then only subtypes of
* {@link com.google.gwt.user.client.rpc.IsSerializable IsSerializable} or
* types which have custom field serializers may be encoded.
* </p>
*
* @param MappedMethod serviceMethod the method that threw the exception, may be
* <code>null</code>
* @param Exception cause the {@link Throwable} that was thrown
* @param SerializationPolicy serializationPolicy determines the serialization policy to be used
* @return a string that encodes the exception
*
* @throws NullPointerException if the the cause or the serializationPolicy
* are <code>null</code>
* @throws SerializationException if the result cannot be serialized
* @throws UnexpectedException if the result was an unexpected exception (a
* checked exception not declared in the serviceMethod's signature)
*/
public static function encodeResponseForFailure(MappedMethod $serviceMethod = null, Exception $cause, SerializationPolicy $serializationPolicy = null, MappedClassLoader $mappedClassLoader)
{
if ($cause === null) {
throw new NullPointerException("cause cannot be null");
}
if ($serializationPolicy === null) {
$serializationPolicy = RPC::getDefaultSerializationPolicy();
//throw new NullPointerException("serializationPolicy");
}
if ($serviceMethod != null && !RPC::isExpectedException($serviceMethod, $cause)) {
class_exists('UnexpectedException') || (require GWTPHP_DIR . '/exceptions/UnexpectedException.class.php');
throw new UnexpectedException("Service method '" . RPC::getSourceRepresentation($serviceMethod) . "' threw an unexpected exception: " . $cause->__toString(), $cause);
}
//class_exists('UnimplementedOperationException') || require(GWTPHP_DIR.'/exceptions/UnimplementedOperationException.class.php');
//throw new UnimplementedOperationException("Exception serialization not implemented yet! " . print_r($cause,true));
//ArrayMappedClassLoader::loadMappedClass('pl.rmalinowski.gwtphp.client.dto.SimpleException');
$couseClass = $mappedClassLoader->findMappedClassByReflectionClass(new ReflectionObject($cause));
return RPC::encodeResponse($couseClass, $cause, true, $serializationPolicy);
// return RPC::encodeResponse($cause.getClass(), $cause, true, $serializationPolicy);
}