本文整理匯總了PHP中Psr\Http\Message\ResponseInterface::resourceNotFoundException方法的典型用法代碼示例。如果您正苦於以下問題:PHP ResponseInterface::resourceNotFoundException方法的具體用法?PHP ResponseInterface::resourceNotFoundException怎麽用?PHP ResponseInterface::resourceNotFoundException使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Psr\Http\Message\ResponseInterface
的用法示例。
在下文中一共展示了ResponseInterface::resourceNotFoundException方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __invoke
public function __invoke(Request $req, Response $res, $args = [])
{
$vaultName = $args['vaultName'];
$jobID = $args['jobID'];
if (!($vault = Vault::get($vaultName))) {
return $res->resourceNotFoundException();
}
if (!($job = $vault->getJob($jobID))) {
return $res->resourceNotFoundException();
}
return $res->withJson($job->serializeArray(true), 200, JSON_PRETTY_PRINT);
}
示例2: __invoke
public function __invoke(Request $req, Response $res, $args = [])
{
$vaultName = $args['vaultName'];
$jobID = $args['jobID'];
if (!empty($GLOBALS['config']['throwResourceNotFoundExceptionForGetJobOutput'])) {
return $res->resourceNotFoundException();
}
if (!($vault = Vault::get($vaultName))) {
return $res->resourceNotFoundException();
}
if (!($job = $vault->getJob($jobID))) {
return $res->resourceNotFoundException();
}
if (!$job->hasOutput()) {
return $res->resourceNotFoundException();
}
$range = false;
$httpRange = false;
if ($job->getAction() === 'ArchiveRetrieval') {
$rangeFrom = 0;
$rangeTo = filesize($job->getArchive()->getFile('data')) - 1;
if ($rangeHeader = $job->getParam('RetrievalByteRange')) {
if (!preg_match('@([0-9]+)?-([0-9]+)@', $rangeHeader, $m)) {
return $res->withStatus(400);
}
$rangeFrom = $m[1];
$rangeTo = $m[2];
}
if ($rangeHeader = $req->getHeaderLine('Range')) {
if (!preg_match('@([0-9]+)?-([0-9]+)@', $rangeHeader, $m)) {
return $res->withStatus(400);
}
$httpRange = [$m[1], $m[2]];
$oRangeFrom = $rangeFrom;
$oRangeTo = $rangeTo;
$rangeLen = $m[2] - $m[1] + 1;
$rangeFrom = $oRangeFrom + $m[1];
$rangeTo = $oRangeFrom + (int) $m[2];
}
$range = [$rangeFrom, $rangeTo];
}
return $job->dumpOutput($res, $range, $httpRange);
}