sidus/base-serializer-bundle
最新稳定版本:v1.0.3
Composer 安装命令:
composer require sidus/base-serializer-bundle
包简介
Additional serializer features for Symfony 3 & 4
关键字:
README 文档
README
Serializer
The NestedPropertyDenormalizer can be very useful for denormalizing API responses into proper model entities, it works without any setters and can denormalize embed data and embed entity collections based on very simple annotations.
This denormalizer will only work on PHP classes with the @NestedPropertyDenormalizer annotation.
Configuration
Configuration example
<?php namespace FooBar\Model; use Sidus\BaseSerializerBundle\Serializer\Annotation\NestedClass; use Sidus\BaseSerializerBundle\Serializer\Annotation\NestedPropertyDenormalizer; /** * @NestedPropertyDenormalizer() */ class Book { /** @var string */ protected $id; /** * @var \DateTimeInterface|null * * @NestedClass(targetClass="DateTime") */ protected $publicationDate; /** * @var Author|null * * @NestedClass(targetClass="FooBar\Model\Author") */ protected $author; /** * @var Edition[] * * @NestedClass(targetClass="FooBar\Model\Edition", multiple=true) */ protected $editions = []; // Here be getters (no setters needed) }
Note that the @NestedClass annotation can target any class.
Additional services
This bundle also features additional services that can be used by other bundles. Implementation details are not provided as they are only needed in custom normalizers.
统计信息
- 总下载量: 9.09k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2019-05-18