定制 sidus/base-serializer-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-05-18