2017 © Pedro Peláez
 

library serializer-extra-bundle

This bundle provides some extra features for serialization

image

hshn/serializer-extra-bundle

This bundle provides some extra features for serialization

  • Friday, January 23, 2015
  • by hshn
  • Repository
  • 1 Watchers
  • 2 Stars
  • 1,406 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 5 % Grown

The README.md

HshnSerializerExtraBundle

Build Status Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

This bundle provides some extra features for serialization., (*2)

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., (*3)

{
    "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, (*4)

# 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., (*5)

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

Export images as URLs

This feature require LiipImagineBundle, (*6)

Adding a filter name specification to a file configuration., (*7)

# 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"
}

The Versions

23/01 2015

dev-master

9999999-dev

This bundle provides some extra features for serialization

  Sources   Download

MIT

The Requires

 

The Development Requires

by Shota Hoshino

15/01 2015
04/01 2015

v0.4.0

0.4.0.0

This bundle provides some extra features for serialization

  Sources   Download

MIT

The Requires

 

The Development Requires

by Shota Hoshino

31/12 2014

v0.3.0

0.3.0.0

This bundle provides some extra features for serialization

  Sources   Download

MIT

The Requires

 

The Development Requires

by Shota Hoshino

31/12 2014

v0.2.0

0.2.0.0

This bundle provides some extra features for serialization

  Sources   Download

MIT

The Requires

 

The Development Requires

by Shota Hoshino

21/12 2014

v0.1.0

0.1.0.0

This bundle provides some extra features for serialization

  Sources   Download

MIT

The Requires

 

The Development Requires

by Shota Hoshino