2017 © Pedro Peláez
 

symfony-bundle serialization-group-bundle

Provides a way to organize serialization groups through configuration

image

gl3n/serialization-group-bundle

Provides a way to organize serialization groups through configuration

  • Tuesday, March 8, 2016
  • by gl3n
  • Repository
  • 2 Watchers
  • 3 Stars
  • 6,564 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 6 % Grown

The README.md

SerializationGroupBundle Build Status

SerializationGroupBundle provides a way to organize serialization groups through configuration., (*1)

It is useful to use with Symfony Serializer component or JMS Serializer., (*2)

1. Installation

Install the bundle through composer, then add it to your AppKernel.php file :, (*3)

$bundles = array(
    // ...
    new Gl3n\SerializationGroupBundle\Gl3nSerializationGroupBundle(),
);

2. Configuration

Here is a sample configuration :, (*4)

gl3n_serialization_group:
    groups:
        group2:
            roles: [ROLE_USER]
        group3:
            roles: [ROLE_ADMIN]
            include: [group2]
        group4:
            roles: [ROLE_SUPER_ADMIN]
            include: [group1, group3]

You can fill on each group :, (*5)

  • roles (optional) : an array of security roles allowed to use this group
  • include (optional) : an array of included groups

3. Usage

Call the serialization group resolver (gl3n_serialization_group.resolver) in order to get the built groups list., (*6)

For example, with the previous sample configuration :, (*7)

// Resolving group1 returns ['group1']
$groups = $resolver->resolve('group1');

// Resolving group3 returns ['group2', 'group3']
$groups = $resolver->resolve('group3');

// Resolving group4 returns ['group1', 'group2', 'group3', 'group4']
$groups = $resolver->resolve('group4');

3.1. Authorization checker

Security roles are checked during resolution. If user has not the required role a Symfony\Component\Security\Core\Exception\AccessDeniedException is thrown., (*8)

3.2. Example

You can organise entity serialization groups by size (small, medium, large) and serialize several entities at once like that :, (*9)

# config.yml
gl3n_serialization_group:
    groups:
        book_M:
            roles: [ROLE_USER]
            include: [book_S, author_S]
        book_L:
            roles: [ROLE_ADMIN]
            include: [book_M, author_M]
        author_M:
            include: [author_S]

In this example, a book has one or many authors., (*10)

The Versions

08/03 2016

dev-master

9999999-dev

Provides a way to organize serialization groups through configuration

  Sources   Download

The Requires

 

The Development Requires

by Glen Jaguin

serialization group deserialization

08/03 2016

1.0.1

1.0.1.0

Provides a way to organize serialization groups through configuration

  Sources   Download

The Requires

 

The Development Requires

by Glen Jaguin

serialization group deserialization

27/03 2015

1.0.0

1.0.0.0

Provides a way to organize serialization groups through configuration

  Sources   Download

The Requires

 

The Development Requires

by Glen Jaguin

serialization group deserialization