當前位置: 首頁>>代碼示例>>PHP>>正文


PHP JsonResponse::isNotModified方法代碼示例

本文整理匯總了PHP中Symfony\Component\HttpFoundation\JsonResponse::isNotModified方法的典型用法代碼示例。如果您正苦於以下問題:PHP JsonResponse::isNotModified方法的具體用法?PHP JsonResponse::isNotModified怎麽用?PHP JsonResponse::isNotModified使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\HttpFoundation\JsonResponse的用法示例。


在下文中一共展示了JsonResponse::isNotModified方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: defaultAction

 static function defaultAction(Request $request, Service $service, $repositoryName)
 {
     $repository = $service->getRepository($repositoryName);
     if ($repository) {
         $response = new JsonResponse();
         $etag = md5($repository->getLastModifiedDate());
         $response->setEtag($etag);
         if ($response->isNotModified($request)) {
             $response->send();
             return $response;
         }
         $result = [];
         $result['content'] = [];
         foreach ($repository->getContentTypeDefinitions() as $definition) {
             $result['content'][$definition->getName()]['title'] = $definition->getTitle() ? $definition->getTitle() : $definition->getName();
             $result['content'][$definition->getName()]['lastchange_content'] = $repository->getLastModifiedDate($definition->getName());
             $result['content'][$definition->getName()]['lastchange_cmdl'] = 0;
             // TODO
         }
         $response->setContent(json_encode($result, JSON_PRETTY_PRINT));
         $response->setEtag($etag);
         $response->setPublic();
         return $response;
     }
 }
開發者ID:nhagemann,項目名稱:anycontent-repository-service-php,代碼行數:25,代碼來源:Info.php

示例2: getJsonResponse

 /**
  * @param Request $request
  * @param mixed   $data
  *
  * @return JsonResponse
  */
 protected function getJsonResponse(Request $request, $data = null)
 {
     $date = new \DateTime();
     $date->modify('+1 day');
     $response = new JsonResponse($data);
     $response->setExpires($date);
     $response->setETag(md5($response->getContent()));
     $response->setPublic();
     $response->isNotModified($request);
     $response->headers->set('X-Proudly-Crafted-By', "LesPolypodes.com");
     // It's nerdy, I know that.
     return $response;
 }
開發者ID:philippgerard,項目名稱:GoogleDrive-based-DMS,代碼行數:19,代碼來源:ApiController.php

示例3: getListAction

 public function getListAction(Application $app)
 {
     $userList = $this->repository->findAll();
     $date = new \DateTime();
     $date->modify('+' . self::MAX_AGE . ' seconds');
     $response = new JsonResponse($userList, JsonResponse::HTTP_OK);
     $responseHash = sha1($response->getContent());
     $response->setMaxAge(self::MAX_AGE);
     $response->setSharedMaxAge(self::MAX_AGE);
     $response->setExpires($date);
     $response->setETag($responseHash);
     $response->isNotModified($app['request']);
     return $response;
 }
開發者ID:tecnom1k3,項目名稱:insta-api,代碼行數:14,代碼來源:User.php


注:本文中的Symfony\Component\HttpFoundation\JsonResponse::isNotModified方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。