本文整理汇总了PHP中JSONMessage::timestamp方法的典型用法代码示例。如果您正苦于以下问题:PHP JSONMessage::timestamp方法的具体用法?PHP JSONMessage::timestamp怎么用?PHP JSONMessage::timestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONMessage
的用法示例。
在下文中一共展示了JSONMessage::timestamp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getType
/**
Tries to find a response handler for $request->getType().
$request must be one of:
- A JSONRequest object. Its getType() value is used
as the handler lookup key.
- An array, in which case the JSONRequest($request)
is called to construct a request.
- A string containing '{', in which case it is assumed
to be message JSON and is passed on to JSONRequest($request).
- A string containing a lookup key. If it is found, the response
handler is passed that key rather than a JSONRequest() object.
If $f is a string and does not map to a current entry then
paths which have been registered in addAutoloadDir() are searched
for a file names EVENT_TYPE.inc.php. If one is found, it is
include and the mapping is re-checked (because presumably the
file will register a handler).
Returns:
If no handler is found, null is returned. If one is found,
it is handled as described in mapResponder()
and on success a JSONResponder is returned. If an error is encountered
in the handling of the request, the contained response will
be a wrapper for that error.
*/
public static function getResponder($request)
{
$key = null;
function reportError($r, $msg)
{
return new JSONResponder_Error($r, __CLASS__ . '::getResponder(): ' . $msg);
}
if (is_string($request)) {
if (false === strpos($request, '{')) {
$key = $request;
} else {
try {
$request = new JSONRequest($request);
$key = $request->getType();
} catch (Exception $e) {
if (1) {
throw $e;
} else {
return new JSONResponder_Error(null, "EXCEPTION while creating JSONRequest from request data: " . $e->getMessage());
}
}
}
} else {
if ($request instanceof JSONRequest) {
$key = $request->getType();
} else {
if (@is_array($request)) {
$request = new JSONRequest($request);
$key = $request->getType();
} else {
// TODO: create an Exception response type to wrap this, and return it:
return new JSONResponder_Error(new JSONRequest(), "Illegal arguments to " . __CLASS__ . "::getResponder([unknown])");
}
}
}
$f = @self::$handlers[$key];
$request->set('arrivalTime', $request->get('arrivalTime', JSONMessage::timestamp()));
while (!$f) {
foreach (self::$DispatcherPath as $dir) {
$fn = $dir . '/' . $key . '.inc.php';
if (@file_exists($fn)) {
require_once $fn;
$f = @self::$handlers[$key];
break;
}
}
if (!$f) {
return null;
}
//reportErr($request,"No Responder found for message type '".$key."'.");
break;
}
if (is_string($f)) {
if (class_exists($f)) {
$x = new $f($request);
if ($x instanceof JSONResponder) {
return $x;
} else {
if ($x instanceof JSONResponse) {
return new JSONResponder_Generic($request, $x);
} else {
return reportError($r, "class mapped to [" . $key . "] is neither " . "a JSONResponder nor a JSONResponse!");
}
}
} else {
if (function_exists($f)) {
$x = $f($request);
if ($x instanceof JSONResponder) {
return $x;
//.........这里部分代码省略.........