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


PHP Response::withJson方法代码示例

本文整理汇总了PHP中Slim\Http\Response::withJson方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::withJson方法的具体用法?PHP Response::withJson怎么用?PHP Response::withJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Slim\Http\Response的用法示例。


在下文中一共展示了Response::withJson方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getUserDetails

 public function getUserDetails(Request $request, Response $response, $arguments)
 {
     $user = $this->container->user;
     if ($user) {
         return $response->withJson($user, 200, JSON_PRETTY_PRINT);
     }
 }
开发者ID:joppuyo,项目名称:Dullahan,代码行数:7,代码来源:UserController.php

示例2: render

 /**
  * @param Response $response
  * @param int      $status
  *
  * @return ResponseInterface
  */
 public function render(Response $response, $status = 200)
 {
     // Put the default top-level members into $result object
     $result = new \StdClass();
     $result->data = $this->data;
     $result->errors = $this->errors;
     return $response->withJson($result, $status);
 }
开发者ID:cristianp6,项目名称:slim-json-api-helper,代码行数:14,代码来源:Renderer.php

示例3: listFeeds

 /**
  * @param Request $request
  * @param Response $response
  * @return Response
  */
 public function listFeeds(Request $request, Response $response)
 {
     $list = $this->getModel()->getCondensedList();
     $feeds = [];
     foreach ($list as $feed) {
         $feed->id = $feed->_id->__toString();
         $feeds[] = $feed;
     }
     return $response->withJson($feeds, 200);
 }
开发者ID:alexdebril,项目名称:feedio-demo,代码行数:15,代码来源:Feed.php

示例4: render

 public function render(Response $response, $code, $data)
 {
     if (is_array($data)) {
         foreach ($data as $key => $value) {
             $data[$key] = $this->_checkForParsing($value);
         }
     } else {
         $data = $this->_checkForParsing($data);
     }
     return $response->withJson($data, $code);
 }
开发者ID:Gerschtli,项目名称:time-manager,代码行数:11,代码来源:Data.php

示例5: index

 public function index(Request $request, Response $response, array $args)
 {
     /** @var Careers $career */
     $career = $this->data(Careers::class);
     /** @var \PDOStatement $portfolio */
     $portfolio = $this->data(MemberPortfolios::class)->find(['member_portfolio_id' => (int) $args['id'], 'user_id' => $this->session->get('user_id'), 'deleted' => 'N']);
     if ($request->isXhr()) {
         return $response->withJson($portfolio->fetch());
     }
     $this->view->addData(['career_levels' => array_pairs($career->getLevels(), 'career_level_id'), 'industries' => array_pairs($career->getIndustries(), 'industry_id', 'industry_name')], 'sections::portfolio-form');
     $this->setPageTitle('Membership', 'Update portfolio item');
     return $this->view->render('portfolio-edit', ['portfolio' => $portfolio->fetch()]);
 }
开发者ID:aswitahidayat,项目名称:phpindonesia.or.id-membership2,代码行数:13,代码来源:PortfoliosController.php

示例6: __invoke

 public function __invoke(Request $req, Response $res)
 {
     $identity = $this->authService->getIdentity();
     if (null === $identity) {
         return $res;
     }
     $user = R::load('user', $identity->id);
     if (!$user->school_id) {
         return $res;
     }
     $school_id = $user->school_id;
     $sync = $this->syncFromInventory;
     $result = $sync($school_id);
     if (false === $result) {
         return $res->withStatus(500);
     }
     return $res->withJson($result);
 }
开发者ID:eellak,项目名称:gredu_labs,代码行数:18,代码来源:Sync.php

示例7: updateContent

 public function updateContent(Request $request, Response $response, $arguments)
 {
     $data = $request->getParsedBody();
     if (!$data) {
         return $response->withJson(['message' => 'Could not parse JSON', 'errorCode' => 'JSON_PARSE_ERROR'], 400);
     }
     $content = Content::find($arguments['contentId']);
     if (!$content) {
         return $response->withJson(['message' => 'Content not found', 'errorCode' => 'CONTENT_NOT_FOUND'], 404);
     }
     $contentType = $this->container->ContentService->getContentTypeDefinition($content->content_type);
     $fields = new \stdClass();
     foreach ($contentType->fields as $currentField) {
         if (array_key_exists($currentField->slug, $data)) {
             $fields->{$currentField->slug} = $data[$currentField->slug];
         }
     }
     $content->fields = $fields;
     $content->save();
     // TODO: return modified object
     return $response->withJson($this->container->ContentService->convertFields($content, $contentType, $request), 201);
 }
开发者ID:joppuyo,项目名称:Dullahan,代码行数:22,代码来源:ContentController.php

示例8: skillsCookie

 public function skillsCookie(Request $request, Response $response, array $args)
 {
     $cookie = $request->getCookieParams();
     if (!isset($cookie['skill-popup'])) {
         setcookie('skill-popup', 1, $this->cookieTtl());
     }
     return $response->withJson(['resp' => 'OK']);
 }
开发者ID:phpindonesia,项目名称:phpindonesia.or.id-membership2,代码行数:8,代码来源:AccountController.php

示例9: responseWithDenial

 /**
  * @param \Slim\Http\Request  $request
  * @param \Slim\Http\Response $response
  * @return \Slim\Http\Response
  */
 private function responseWithDenial(Request $request, Response $response)
 {
     $message = 'Permission denied, authorization required.';
     // Response with json if XHR request
     if ($request->isXhr()) {
         return $response->withJson(['message' => $message], 401);
     }
     // Response with redirect if otherwise
     $this->flash->addMessage('error', $message);
     return $response->withRedirect($this->router->pathFor('membership-account'));
 }
开发者ID:aswitahidayat,项目名称:phpindonesia.or.id-membership2,代码行数:16,代码来源:Middleware.php

示例10: uploadMedia

 public function uploadMedia(Request $request, Response $response, $arguments)
 {
     $errors = [];
     foreach ($_FILES as $key => $file) {
         $storage = new \Upload\Storage\FileSystem('uploads');
         $file = new \Upload\File($key, $storage);
         try {
             $file->setName(s($file->getName())->slugify());
             $file->upload();
         } catch (\Exception $e) {
             array_push($errors, 'Failed to upload ' . $file->getNameWithExtension());
         }
     }
     return $response->withJson(['errors' => $errors], 200, JSON_PRETTY_PRINT);
 }
开发者ID:joppuyo,项目名称:Dullahan,代码行数:15,代码来源:MediaController.php

示例11: json

 /**
  * Output JSON info about the video.
  *
  * @param Request  $request  PSR-7 request
  * @param Response $response PSR-7 response
  *
  * @return Response HTTP response
  */
 public function json(Request $request, Response $response)
 {
     $params = $request->getQueryParams();
     if (isset($params['url'])) {
         try {
             $video = $this->download->getJSON($params['url']);
             return $response->withJson($video);
         } catch (\Exception $e) {
             return $response->withJson(['success' => false, 'error' => $e->getMessage()]);
         }
     }
 }
开发者ID:rudloff,项目名称:alltube,代码行数:20,代码来源:FrontController.php

示例12: find

 /**
  * Find a user
  */
 public function find(Request $request, Response $response, array $args)
 {
     return $response->withJson(UserModel::find($args["uid"]));
 }
开发者ID:folkevil,项目名称:Skeleton-API,代码行数:7,代码来源:User.php

示例13: listApps

 public function listApps(Request $request, Response $response, $arguments)
 {
     $apps = App::all();
     return $response->withJson($apps, 200, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
 }
开发者ID:joppuyo,项目名称:Dullahan,代码行数:5,代码来源:AppController.php

示例14: remove

 /**
  * @param Request $request
  * @param Response $response
  * @param $args
  *
  * @return ResponseInterface
  */
 public function remove(Request $request, Response $response, $args)
 {
     try {
         $result = $this->gateway->delete($this->getIdArray($args));
         return $response->withJson(["result" => $result]);
     } catch (\Exception $e) {
         return $response->withStatus(400);
     }
 }
开发者ID:geggleto,项目名称:slimgateway,代码行数:16,代码来源:EntityController.php

示例15: deleteRelationsAction

 /**
  * Delete organizations relations action
  *
  * @param Request $request
  * @param Response $response
  * @param array $args
  *
  * @return Response
  */
 public function deleteRelationsAction(Request $request, Response $response, $args)
 {
     $this->service->removeOrganizations();
     return $response->withJson(null, 204);
 }
开发者ID:EugeneKirillov,项目名称:organization-relationships,代码行数:14,代码来源:OrganizationsController.php


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