承接 hshn/serializer-extra-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

hshn/serializer-extra-bundle

最新稳定版本:v0.4.1

Composer 安装命令:

composer require hshn/serializer-extra-bundle

包简介

This bundle provides some extra features for serialization

README 文档

README

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

This bundle provides some extra features for serialization.

Exporting authorities of objects

# app/config.yml
hshn_serializer_extra:
    authority:
        classes:
            AcmeBundle\Entity\Blog:
                attributes: OWNER
/** @var $serializer JMS\Serializer\Serializer */
$json = $serializer->serialize($blog, 'json');

The access authorities provided by AuthorizationCheckerInterface::isGranted() will be exported to the attribute '_authority' when an object was serialized.

{
    "key": "value",
    "_authority": {
        "OWNER": true
    }
}

Overriding the attribute name

# app/config.yml
hshn_serializer_extra:
    authority:
        export_to: "my_authority"
{
    "key": "value",
    "my_authority": {
        "OWNER": true
    }
}

Restrict exporting the authorities by depth

# app/config.yml
hshn_serializer_extra:
    authority:
        classes:
            AcmeBundle\Entity\Blog:
                attributes: [OWNER]
                max_depth: 0 # default -1 (unlimited)
class Blog
{
}

class User
{
    /**
     * @var Blog
     */
    private $blog;
}

$serializer->serialize($blog, 'json'); // will export the blog authorities (depth 0)
$serializer->serialize($user, 'json'); // will NOT export the blog authorities (depth 1)

Export files as URLs

This feature require VichUploaderBundle

# app/config.yml
hshn_serializer_extra:
    vich_uploader:
        classes:
            AcmeBundle\Entity\Blog:
                files:
                    - { property: picture }
                    - { property: picture, export_to: image }
/** @var $serializer JMS\Serializer\Serializer */
$json = $serializer->serialize($blog, 'json');

Generated URLs will be exported when serializing an object.

{
    "picture": "/url/to/picture",
    "image": "/url/to/picture"
}

Export images as URLs

This feature require LiipImagineBundle

Adding a filter name specification to a file configuration.

# app/config.yml
hshn_serializer_extra:
    vich_uploader:
        classes:
            AcmeBundle\Entity\Blog:
                files:
                    - { property: picture }
                    - { property: picture, export_to: image, filter: thumbnail }
{
    "picture": "/url/to/picture",
    "image": "/url/to/thumbnail/picture"
}

统计信息

  • 总下载量: 1.48k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-12-13