Symfony framework integration of the yceruto/decorator
library.
- Enables decoration capabilities for Symfony controllers.
Open a command console, enter your project directory and execute:
$ composer require yceruto/decorator-bundle
- Compound
See https://github.com/yceruto/decorator README.md
file for details.
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...
}
}
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 contextstatus
the response status (default: 200)headers
the response headers
Example:
class MyController
{
#[Serialize]
public function __invoke(): array
{
return ['success' => true];
}
}
This software is published under the MIT License