当前位置: 首页>>代码示例>>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;未经允许,请勿转载。