当前位置: 首页>>代码示例>>PHP>>正文


PHP ResponseInterface::withJson方法代码示例

本文整理汇总了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);
 }
开发者ID:gurpreetatwal,项目名称:Skeleton-API,代码行数:7,代码来源:ErrorHandler.php

示例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);
 }
开发者ID:sebcode,项目名称:gsandbox,代码行数:8,代码来源:DescribeVaultAction.php

示例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);
 }
开发者ID:sebcode,项目名称:gsandbox,代码行数:9,代码来源:ListVaultsAction.php

示例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));
 }
开发者ID:andrearruda,项目名称:kpi,代码行数:11,代码来源:IndicadorAction.php

示例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);
 }
开发者ID:sebcode,项目名称:gsandbox,代码行数:12,代码来源:ListMultipartUploadsAction.php

示例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);
 }
开发者ID:sebcode,项目名称:gsandbox,代码行数:12,代码来源:ListMultipartUploadPartsAction.php

示例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);
 }
开发者ID:sebcode,项目名称:gsandbox,代码行数:12,代码来源:DescribeJobAction.php

示例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);
 }
开发者ID:sebcode,项目名称:gsandbox,代码行数:12,代码来源:ListJobsAction.php

示例9: searchTabsApi

 public function searchTabsApi(Request $request, Response $response, array $args)
 {
     return $response->withJson($this->container->tabRepository->searchSuggestions($args['term']));
 }
开发者ID:siiptuo,项目名称:tablak,代码行数:4,代码来源:TabController.php

示例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);
 }
开发者ID:arcostasi,项目名称:slimantic-skeleton,代码行数:13,代码来源:JsonViewProvider.php

示例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);
 }
开发者ID:deepsadhi,项目名称:presentation2.0,代码行数:26,代码来源:Controller.php

示例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);
 }
开发者ID:mrmoneyc,项目名称:slim-mvc-skeleton,代码行数:6,代码来源:SystemController.php

示例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);
 }
开发者ID:sebcode,项目名称:gsandbox,代码行数:6,代码来源:GetDataRetrievalPolicyAction.php


注:本文中的Psr\Http\Message\ResponseInterface::withJson方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。