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


PHP SerializerInterface::deserialize方法代码示例

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


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

示例1: __invoke

 /**
  * Create a new item.
  *
  * @param Request    $request
  * @param string|int $id
  *
  * @throws NotFoundHttpException
  * @throws RuntimeException
  * @throws UserProtectedException
  * @throws UserLimitReachedException
  *
  * @return mixed
  */
 public function __invoke(Request $request, $id)
 {
     /**
      * @var $resourceType ResourceInterface
      */
     list($resourceType, $format) = $this->extractAttributes($request);
     /*
      * Workaround to ensure stockLevels are not overwritten in a PUT request.
      * @see https://github.com/partkeepr/PartKeepr/issues/551
      */
     $data = json_decode($request->getContent(), true);
     if (array_key_exists('stockLevels', $data)) {
         unset($data['stockLevels']);
     }
     $requestData = json_encode($data);
     $data = $this->getItem($this->dataProvider, $resourceType, $id);
     $context = $resourceType->getDenormalizationContext();
     $context['object_to_populate'] = $data;
     /**
      * @var $part Part
      */
     $part = $this->serializer->deserialize($requestData, $resourceType->getEntityClass(), $format, $context);
     if (!$this->partService->isInternalPartNumberUnique($part->getInternalPartNumber(), $part)) {
         throw new InternalPartNumberNotUniqueException();
     }
     return $part;
 }
开发者ID:partkeepr,项目名称:PartKeepr,代码行数:40,代码来源:PartPutAction.php

示例2: __invoke

 /**
  * Create a new item.
  *
  * @param Request    $request
  * @param string|int $id
  *
  * @throws NotFoundHttpException
  * @throws RuntimeException
  * @throws UserProtectedException
  * @throws UserLimitReachedException
  *
  * @return mixed
  */
 public function __invoke(Request $request, $id)
 {
     /**
      * @var ResourceInterface
      */
     list($resourceType, $format) = $this->extractAttributes($request);
     /**
      * @var User
      */
     $data = $this->getItem($this->dataProvider, $resourceType, $id);
     $context = $resourceType->getDenormalizationContext();
     $context['object_to_populate'] = $data;
     if ($data->isProtected()) {
         throw new UserProtectedException();
     }
     $data = $this->serializer->deserialize($request->getContent(), $resourceType->getEntityClass(), $format, $context);
     if ($data->isActive()) {
         if ($this->userService->checkUserLimit()) {
             throw new UserLimitReachedException();
         }
     }
     $this->userService->syncData($data);
     $data->setNewPassword('');
     $data->setPassword('');
     $data->setLegacy(false);
     return $data;
 }
开发者ID:partkeepr,项目名称:PartKeepr,代码行数:40,代码来源:PutUserAction.php

示例3: current

 /**
  * {@inheritdoc}
  */
 public function current()
 {
     $result = parent::current();
     if ($result !== null && $this->serializer) {
         $result = $this->serializer->deserialize($result, $this->itemType, null, $this->deserializeContext);
     }
     return $result;
 }
开发者ID:florinmatthew,项目名称:zoho-integration-bundle,代码行数:11,代码来源:AbstractZohoRESTiterator.php

示例4: get

 /**
  * @param $url
  * @param array $params
  *
  * @return array
  */
 public function get($url, $params = array())
 {
     $request = $this->provider->request($url, $params);
     $response = $this->client->send($request);
     $data = $response->getBody()->getContents();
     $format = $this->getFormat($params, $response);
     return $this->serializer->deserialize($data, null, $format);
 }
开发者ID:bangpound,项目名称:oembed,代码行数:14,代码来源:Consumer.php

示例5: __invoke

 /**
  * Create a new item.
  *
  * @param Request    $request
  * @param string|int $id
  *
  * @return mixed
  *
  * @throws NotFoundHttpException
  * @throws RuntimeException
  */
 public function __invoke(Request $request, $id)
 {
     list($resourceType, $format) = $this->extractAttributes($request);
     $data = $this->getItem($this->dataProvider, $resourceType, $id);
     $context = $resourceType->getDenormalizationContext();
     $context['object_to_populate'] = $data;
     $data = $this->serializer->deserialize($request->getContent(), $resourceType->getEntityClass(), $format, $context);
     return $data;
 }
开发者ID:PaskR,项目名称:DunglasApiBundle,代码行数:20,代码来源:PutItemAction.php

示例6: __invoke

 /**
  * Injects the specific root node ID if "@local-tree-root" was specified
  *
  * @param Request $request
  *
  * @return mixed
  *
  * @throws RuntimeException
  * @throws PartLimitExceededException
  */
 public function __invoke(Request $request)
 {
     /**
      * @var $resourceType ResourceInterface
      */
     if ($this->partService->checkPartLimit()) {
         throw new PartLimitExceededException();
     }
     list($resourceType, $format) = $this->extractAttributes($request);
     return $this->serializer->deserialize($request->getContent(), $resourceType->getEntityClass(), $format, $resourceType->getDenormalizationContext());
 }
开发者ID:fulcrum3d,项目名称:PartKeepr,代码行数:21,代码来源:PostAction.php

示例7: process

 /**
  * {@inheritdoc}
  */
 public function process($item)
 {
     if ($this->converter) {
         $item = $this->converter->convertToImportFormat($item);
     }
     $object = $this->serializer->deserialize($item, $this->context->getOption('entityName'), null);
     if ($this->strategy) {
         $object = $this->strategy->process($object);
     }
     return $object ?: null;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:14,代码来源:ImportProcessor.php

示例8: process

 /**
  * {@inheritdoc}
  */
 public function process($item)
 {
     if ($this->dataConverter) {
         $item = $this->dataConverter->convertToImportFormat($item, false);
     }
     $this->context->setValue('itemData', $item);
     $object = $this->serializer->deserialize($item, $this->context->getOption('entityName'), null, $this->context->getConfiguration());
     if ($this->strategy) {
         $object = $this->strategy->process($object);
     }
     return $object ?: null;
 }
开发者ID:xamin123,项目名称:platform,代码行数:15,代码来源:ImportProcessor.php

示例9: createContext

 /**
  * Return a list of class guessed
  *
  * @param $swaggerSpec
  * @param $name
  * @param $namespace
  * @param $directory
  *
  * @return Context
  */
 public function createContext($swaggerSpec, $name, $namespace, $directory)
 {
     $schema = $this->serializer->deserialize(file_get_contents($swaggerSpec), Swagger::class, 'json');
     $classes = $this->chainGuesser->guessClass($schema, $name);
     foreach ($classes as $class) {
         $properties = $this->chainGuesser->guessProperties($class->getObject(), $name, $classes);
         foreach ($properties as $property) {
             $property->setType($this->chainGuesser->guessType($property->getObject(), $property->getName(), $classes));
         }
         $class->setProperties($properties);
     }
     return new Context($schema, $namespace, $directory, $classes);
 }
开发者ID:stof,项目名称:jane-swagger,代码行数:23,代码来源:JaneSwagger.php

示例10: getResponse

 /**
  * @param string $response
  * @param array  $options
  *
  * @return object
  */
 private function getResponse($response, array $options)
 {
     if (is_string($response) && array_key_exists('class', $options)) {
         $response = $this->serializer->deserialize($response, $options['class'], 'json');
     }
     return $response;
 }
开发者ID:sroze,项目名称:kubernetes-client,代码行数:13,代码来源:HttpConnector.php

示例11: getDataFromResponse

 /**
  * Transform a given response into a denormalized PHP object
  * If the config option "returnResponse" is set to TRUE, it return a Response instead
  *
  * @param ResponseInterface $response
  * @param ResponseDefinition $definition
  * @param RequestInterface $request
  *
  * @return Resource|mixed
  */
 private function getDataFromResponse(ResponseInterface $response, ResponseDefinition $definition, RequestInterface $request)
 {
     if ($this->config['returnResponse'] === true) {
         return $response;
     }
     return $this->serializer->deserialize((string) $response->getBody(), Resource::class, DecoderUtils::extractFormatFromContentType($response->getHeaderLine('Content-Type')), ['response' => $response, 'responseDefinition' => $definition, 'request' => $request]);
 }
开发者ID:eleven-labs,项目名称:api-service,代码行数:17,代码来源:ApiService.php

示例12: resolveSchema

 /**
  * Resolve JSON Schema for the reference
  *
  * @param Reference $reference
  * @param JsonSchema $currentSchema
  *
  * @throws UnsupportedException
  *
  * @return JsonSchema Return the json schema referenced
  */
 protected function resolveSchema(Reference $reference, $currentSchema)
 {
     if ($reference->isInCurrentDocument() && $reference->hasFragment()) {
         return $currentSchema;
     }
     if ($reference->isRelative() && !$currentSchema->getId()) {
         throw new UnsupportedException(sprintf("Reference is relative and no id found in current schema, cannot resolve reference %s", $reference->getReference()));
     }
     // Build url
     $schemaUrl = sprintf('%s://%s:%s', $reference->getScheme() ?: 'http', $reference->getHost(), $reference->getPort() ?: '80');
     if ($reference->isRelative()) {
         $parsedUrl = parse_url($currentSchema->getId());
         $schemaUrl = sprintf('%s://%s:%s', $parsedUrl['scheme'] ?: 'http', $parsedUrl['host'], $parsedUrl['port'] ?: '80');
     }
     if ($reference->getPath()) {
         $schemaUrl = sprintf("%s/%s", $schemaUrl, $reference->getPath());
     }
     if ($reference->getQuery()) {
         $schemaUrl = sprintf("%s?%s", $schemaUrl, $reference->getQuery());
     }
     if (!isset($this->schemaCache[$schemaUrl])) {
         $schema = $this->serializer->deserialize($this->getJsonSchemaContent($schemaUrl), 'Joli\\Jane\\Model\\JsonSchema', 'json');
         $this->schemaCache[$schemaUrl] = $schema;
     }
     return $this->schemaCache[$schemaUrl];
 }
开发者ID:jolicode,项目名称:jane,代码行数:36,代码来源:Resolver.php

示例13: __invoke

 /**
  * Injects the specific root node ID if "@local-tree-root" was specified.
  *
  * @param Request $request
  *
  * @throws RuntimeException
  * @throws PartLimitExceededException
  * @throws InternalPartNumberNotUniqueException
  *
  * @return mixed
  */
 public function __invoke(Request $request)
 {
     if ($this->partService->checkPartLimit()) {
         throw new PartLimitExceededException();
     }
     /**
      * @var $resourceType ResourceInterface
      */
     list($resourceType, $format) = $this->extractAttributes($request);
     /**
      * @var $part Part
      */
     $part = $this->serializer->deserialize($request->getContent(), $resourceType->getEntityClass(), $format, $resourceType->getDenormalizationContext());
     if (!$this->partService->isInternalPartNumberUnique($part->getInternalPartNumber())) {
         throw new InternalPartNumberNotUniqueException();
     }
     return $part;
 }
开发者ID:partkeepr,项目名称:PartKeepr,代码行数:29,代码来源:PartPostAction.php

示例14: loadDomainDistinguishedName

 /**
  * {@inheritdoc}
  */
 public function loadDomainDistinguishedName($domain)
 {
     try {
         $json = $this->master->read('private/' . $domain . '/distinguished_name.json');
         return $this->serializer->deserialize($json, DistinguishedName::class, JsonEncoder::FORMAT);
     } catch (\Exception $e) {
         throw new AcmeCliException(sprintf('Loading of domain %s distinguished name failed', $domain), $e);
     }
 }
开发者ID:acmephp,项目名称:acmephp,代码行数:12,代码来源:Repository.php

示例15: __invoke

 /**
  * Create a new item.
  *
  * @param Request $request
  *
  * @return mixed
  *
  * @throws NotFoundHttpException
  * @throws RuntimeException
  * @throws UserLimitReachedException
  */
 public function __invoke(Request $request)
 {
     /**
      * @var $resourceType ResourceInterface
      */
     list($resourceType, $format) = $this->extractAttributes($request);
     if ($this->userService->checkUserLimit() === true) {
         throw new UserLimitReachedException();
     }
     /**
      * @var User $data
      */
     $data = $this->serializer->deserialize($request->getContent(), $resourceType->getEntityClass(), $format, $resourceType->getDenormalizationContext());
     $data->setProvider($this->userService->getBuiltinProvider());
     $data->setLegacy(false);
     $this->userService->syncData($data);
     $data->setNewPassword("");
     $data->setPassword("");
     return $data;
 }
开发者ID:fulcrum3d,项目名称:PartKeepr,代码行数:31,代码来源:PostUserAction.php


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