yceruto/decorator-bundle

Symfony framework integration of the Decorator library

Installs: 14

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 1

Forks: 0

Open Issues: 0

Type:symfony-bundle

v1.1.0 2024-11-04 04:51 UTC

This package is auto-updated.

Last update: 2024-11-04 04:51:58 UTC


README

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