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


PHP SerializationContext::enableMaxDepthChecks方法代碼示例

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


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

示例1: render

 /**
  * Render the view into a string and return for output
  *
  * @param mixed $input
  * @return string
  * @throws \Exception
  */
 public function render($input = null)
 {
     $context = new SerializationContext();
     $context->setSerializeNull(true);
     $context->enableMaxDepthChecks();
     FrontController::getInstance()->getResponse()->headers->set('Content-Type', 'application/json');
     return $this->serializer->serialize($input, $this->format, $context);
 }
開發者ID:epoplive,項目名稱:pillow,代碼行數:15,代碼來源:DoctrineAnnotationTemplateView.php

示例2: getMonsterAction

 /**
  * @Route("/monster/{id}", methods={"GET"}, requirements={"id"="^[0-9].*$"})
  * @param Monster $monster
  * @return Monster
  */
 public function getMonsterAction(Monster $monster)
 {
     $serializer = $this->get("jms_serializer");
     $context = new SerializationContext();
     $context->enableMaxDepthChecks();
     $response = new Response($serializer->serialize($monster, 'json', $context));
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
開發者ID:samisalami,項目名稱:xenobladex-org,代碼行數:14,代碼來源:MonsterController.php

示例3: getCollectionCategoryAction

 /**
  * @Route("/collection/category/{id}", methods={"GET"}, requirements={"id"="^[0-9].*$"})
  * @param CollectionCategory $collectionCategory
  * @return CollectionCategory
  */
 public function getCollectionCategoryAction(CollectionCategory $collectionCategory)
 {
     $serializer = $this->get("jms_serializer");
     $context = new SerializationContext();
     $context->enableMaxDepthChecks();
     $response = new Response($serializer->serialize($collectionCategory, 'json', $context));
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
開發者ID:samisalami,項目名稱:xenobladex-org,代碼行數:14,代碼來源:CollectionCategoryController.php

示例4: buildMultiObjectResponse

 /**
  * @param PaginationInterface $pagination
  * @param Request             $request
  * @param Router              $router
  * @param array               $serializationGroups
  *
  * @return mixed
  */
 public function buildMultiObjectResponse(PaginationInterface $pagination, Request $request, Router $router, array $serializationGroups = array())
 {
     if (empty($pagination->getItems())) {
         return $this->handle(View::create(null, Response::HTTP_NO_CONTENT));
     }
     $paginationData = $pagination->getPaginationData();
     $link = $this->buildPaginationLink($paginationData, $request, $router);
     $headers = [];
     if (!empty($link)) {
         $headers['Link'] = $link;
     }
     if (isset($paginationData['totalCount'])) {
         $headers['X-Total-Count'] = $paginationData['totalCount'];
     }
     $view = View::create($pagination->getItems(), Response::HTTP_OK, $headers);
     $context = new SerializationContext();
     $context->setSerializeNull(true);
     $context->enableMaxDepthChecks();
     if (!empty($serializationGroups)) {
         $context->setGroups($serializationGroups);
     }
     $view->setSerializationContext($context);
     return $this->handle($view);
 }
開發者ID:Cute-Ninja,項目名稱:parabola-bundle,代碼行數:32,代碼來源:SuccessResponseBuilder.php

示例5: createSerializationContext

 /**
  * Create serialization context with settings taken from the controller's annotation
  *
  * @param MappingInterface $mapping
  * @return SerializationContext
  */
 protected function createSerializationContext(MappingInterface $mapping)
 {
     $context = new SerializationContext();
     if ($mapping->getAnnotation()->getSerializerEnableMaxDepthChecks()) {
         $context->enableMaxDepthChecks();
     }
     if ($mapping->getAnnotation()->getSerializerGroups()) {
         $context->setGroups($mapping->getAnnotation()->getSerializerGroups());
     }
     if ($mapping->getAnnotation()->getSerializerSerializeNull()) {
         $context->setSerializeNull(true);
     }
     return $context;
 }
開發者ID:TNAJanssen,項目名稱:ThruwayBundle,代碼行數:20,代碼來源:WampKernel.php

示例6: formatItem

 /**
  * Serializes an object.
  *
  * Implements FormatterInterface::formatItem($item)
  *
  * @param mixed $item
  *
  * @return array
  */
 public function formatItem($item, $format = 'json')
 {
     $formatted = null;
     switch ($format) {
         case 'json':
             // serialize properties with null values
             $context = new SerializationContext();
             $context->setSerializeNull(true);
             $context->enableMaxDepthChecks(true);
             $formatted = $this->getSerializer()->serialize($item, 'json', $context);
             break;
         case 'jsonp':
             $callback = $this->getRequest()->query->get('jsonp.callback', 'JSONP.callback');
             // validate against XSS
             $validator = new \JsonpCallbackValidator();
             if (!$validator->validate($callback)) {
                 throw new BadRequestHttpException('Invalid JSONP callback value');
             }
             $context = new SerializationContext();
             $context->setSerializeNull(true);
             $json = $this->getSerializer()->serialize($item, 'json');
             $formatted = sprintf('/**/%s(%s)', $callback, $json);
             break;
         default:
             // any other format is not supported
             throw new \InvalidArgumentException(sprintf('Format not supported: %s', $format));
     }
     return $formatted;
 }
開發者ID:mickaelsteinberg,項目名稱:BackBee,代碼行數:38,代碼來源:AbstractRestController.php


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