Skip to content

yceruto/decorator-bundle

Repository files navigation

DecoratorBundle

GitHub Actions Workflow Status Version PHP GitHub License

Symfony framework integration of the yceruto/decorator library.

  • Enables decoration capabilities for Symfony controllers.

Installation

Open a command console, enter your project directory and execute:

$ composer require yceruto/decorator-bundle

Native Decorators

  • Compound

See https://github.com/yceruto/decorator README.md file for details.

Bundle Decorators

Transactional

A Doctrine ORM decorator that wraps persistence method operations within a single Doctrine transaction. In case you're using multiple entity managers, you can pass the name of the entity manager as parameter.

Example:

class MyController
{
    #[Transactional(name: 'secondary')]
    public function __invoke(Request $request): Response
    {
        // multiple persistence operations...
    }
}

Serialize

A Serializer decorator that encode the result of your controller into a specific format (default: json).

Options:

  • format the serialization format (default: json)
  • context the serialization context
  • status the response status (default: 200)
  • headers the response headers

Example:

class MyController
{
    #[Serialize]
    public function __invoke(): array
    {
        return ['success' => true];
    }
}

License

This software is published under the MIT License

About

Symfony integration for Decorator library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages