本文整理汇总了PHP中Psr\Http\Message\ResponseInterface::withJson方法的典型用法代码示例。如果您正苦于以下问题:PHP ResponseInterface::withJson方法的具体用法?PHP ResponseInterface::withJson怎么用?PHP ResponseInterface::withJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Psr\Http\Message\ResponseInterface
的用法示例。
在下文中一共展示了ResponseInterface::withJson方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleNestedValidationException
private function handleNestedValidationException()
{
/** @var NestedValidationException $e */
$e = $this->e;
$messages = $this->formatMessages($e);
return $this->response->withJson($e->getFullMessage(), 400);
}
示例2: __invoke
public function __invoke(Request $req, Response $res, $args = [])
{
$vaultName = $args['vaultName'];
if (!($v = Vault::get($vaultName))) {
return $res->withStatus(404);
}
return $res->withJson($v->serializeArray(), 200, JSON_PRETTY_PRINT);
}
示例3: __invoke
public function __invoke(Request $req, Response $res, $args = [])
{
$ret = [];
foreach (Vault::all() as $vault) {
$ret[] = $vault->serializeArray();
}
$jsonResponse = ['Marker' => null, 'VaultList' => $ret];
return $res->withJson($jsonResponse, 200, JSON_PRETTY_PRINT);
}
示例4: active
public function active(Request $request, Response $response, $args)
{
$query_builder = $this->getIndicadorService()->getEntityManager()->createQueryBuilder();
$query_builder->update('App\\Entity\\Kpi', 'kpi')->set('kpi.active', '0')->getQuery()->execute();
$em = $this->getIndicadorService()->getEntityManager();
$kpi = $em->getRepository('App\\Entity\\Kpi')->findOneById($args['id']);
$kpi->setActive(1);
$em->persist($kpi);
$em->flush();
return $response->withJson((new ClassMethods())->extract($kpi));
}
示例5: __invoke
public function __invoke(Request $req, Response $res, $args = [])
{
$vaultName = $args['vaultName'];
if (!($vault = Vault::get($vaultName))) {
return $res->withStatus(404);
}
$jsonResponse = ['UploadsList' => []];
foreach ($vault->getMultiparts() as $m) {
$jsonResponse['UploadsList'][] = $m->serializeArray();
}
return $res->withJson($jsonResponse, 200, JSON_PRETTY_PRINT);
}
示例6: __invoke
public function __invoke(Request $req, Response $res, $args = [])
{
$vaultName = $args['vaultName'];
$multipartID = $args['multipartID'];
if (!($vault = Vault::get($vaultName))) {
return $res->withStatus(404);
}
if (!($m = $vault->getMultipart($multipartID))) {
return $res->withStatus(404);
}
return $res->withJson($m->serializeArray(true), 200, JSON_PRETTY_PRINT);
}
示例7: __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);
}
示例8: __invoke
public function __invoke(Request $req, Response $res, $args = [])
{
$vaultName = $args['vaultName'];
if (!($vault = Vault::get($vaultName))) {
return $res->withStatus(404);
}
$jsonResponse = ['Marker' => null, 'JobList' => []];
foreach ($vault->getJobs() as $job) {
$jsonResponse['JobList'][] = $job->serializeArray();
}
return $res->withJson($jsonResponse, 200, JSON_PRETTY_PRINT);
}
示例9: searchTabsApi
public function searchTabsApi(Request $request, Response $response, array $args)
{
return $response->withJson($this->container->tabRepository->searchSuggestions($args['term']));
}
示例10: render
/**
* JSON render response.
*
* @param Response $response
* @param array $data Associative array of data to be returned
* @param int $status HTTP status code
* @return Response
*/
public function render(Response $response, $data = [], $status = 200)
{
// Return JSON response
return $response->withJson($data, $status);
}
示例11: json
/**
* Presentation slide as json
*
* @param Request $request
* @param Response $response
* @param Array $args
* @return Response
*/
public function json(Request $request, Response $response, array $args)
{
$path = $this->settings['presentation']['presentation'];
$fileName = substr_replace($args['file'], '.', -3, 1);
$filePath = $path . $fileName;
$slideNumber = (int) preg_replace('/\\D/', '', $args['slide']);
$file = new File($filePath);
$data = [];
if ($file->load() === true) {
$slide = new Slide($filePath);
$data['error'] = false;
$data['slide'] = $slide->renderForAjax($slideNumber);
} else {
$data['error'] = true;
$data['message'] = 'Could not load presentation file.';
}
return $response->withJson($data);
}
示例12: getVersion
public function getVersion(Request $request, Response $response, $args)
{
$this->logger->info("Action: Get Application Version");
$appVersion = ['version' => APP_VERSION, 'build' => APP_BUILD, 'fullVersion' => 'V' . APP_VERSION . '(' . APP_BUILD . ')'];
return $response->withJson($appVersion);
}
示例13: __invoke
public function __invoke(Request $req, Response $res, $args = [])
{
$policy = new DataRetrievalPolicy();
$ruleset = $policy->get();
return $res->withJson($policy->get(), 200, JSON_PRETTY_PRINT);
}