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


PHP NormalizerInterface::denormalize方法代码示例

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


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

示例1: testDenormalizationWithType

 public function testDenormalizationWithType()
 {
     $dummy = $this->getDummy();
     $this->normalizer->addType('dummy', TypehintNormalizerClassDummy::class);
     $this->normalizer->addType('subdummy', TypehintNormalizerSubclassDummy::class);
     $expected = $dummy;
     $normalized = $this->normalizer->normalize($dummy);
     $this->assertTrue($this->normalizer->supportsDenormalization($normalized, RecursiveNormalizerClassDummy::class));
     $actual = $this->normalizer->denormalize($normalized, TypehintNormalizerClassDummy::class);
     $this->assertEquals($expected, $actual);
 }
开发者ID:mihai-stancu,项目名称:serializer,代码行数:11,代码来源:TypehintNormalizerTest.php

示例2: denormalize

 /**
  * @param mixed $data
  * @param string $class
  * @param mixed $format
  * @param array $context
  * @return AbstractTypedAddress
  */
 public function denormalize($data, $class, $format = null, array $context = array())
 {
     /** @var AbstractTypedAddress $result */
     $result = $this->addressNormalizer->denormalize($data, $class, $format, $context);
     if (!empty($data['types']) && is_array($data['types'])) {
         $types = $this->serializer->denormalize($data['types'], static::TYPES_TYPE, $format, $context);
         if ($types) {
             foreach ($types as $type) {
                 $result->addType($type);
             }
         }
     }
     return $result;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:21,代码来源:TypedAddressNormalizer.php

示例3: denormalize

 /**
  * Returns collection of denormalized data
  *
  * @param mixed $data
  * @param string $class
  * @param mixed $format
  * @param array $context
  * @return ArrayCollection
  */
 public function denormalize($data, $class, $format = null, array $context = array())
 {
     if (!is_array($data)) {
         return new ArrayCollection();
     }
     $itemType = $this->getItemType($class);
     if (!$itemType) {
         return new ArrayCollection($data);
     }
     $result = new ArrayCollection();
     foreach ($data as $item) {
         $result->add($this->serializer->denormalize($item, $itemType, $format, $context));
     }
     return $result;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:24,代码来源:CollectionNormalizer.php

示例4: denormalize

 /**
  * {@inheritdoc}
  */
 public function denormalize($data, $class, $format = null, array $context = [])
 {
     if (isset($data['#type'])) {
         $type = $data['#type'];
         unset($data['#type']);
         $data = $this->denormalize($data, $type, $format, $context);
         $data = $this->objectNormalizer->denormalize($data, $type, $format, $context);
         return $data;
     }
     if (is_array($data) || $data instanceof \Traversable) {
         foreach ($data as $key => $value) {
             $data[$key] = $this->serializer->denormalize($value, $class, $format, $context);
         }
     }
     return $data;
 }
开发者ID:dunglas,项目名称:doctrine-json-odm,代码行数:19,代码来源:ObjectNormalizer.php

示例5: handleUpdateRequest

 /**
  * {@inheritdoc}
  */
 public function handleUpdateRequest(Request $request, $identifier)
 {
     $parameters = $request->request->all();
     $resource = $this->getResourceById($identifier);
     $className = ClassUtils::getRealClass(get_class($resource));
     $resource = $this->serializer->denormalize($parameters, $className, self::RESPONSE_FORMAT, ['resource' => $resource]);
     $data = $this->serializer->serialize($resource, self::RESPONSE_FORMAT, ['group' => $this->getResourceType()]);
     $this->manager->updateResource($resource);
     return new Response($data);
 }
开发者ID:wellcommerce,项目名称:wellcommerce,代码行数:13,代码来源:RequestHandler.php


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