本文整理汇总了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);
}