Responders
Responders respond data: transform data to a Symfony response, return a success in a CLI operation.
Default responders
When your operation is an instance of Sylius\Component\Resource\Metadata\HttpOperation
two responders are configured by default.
The responder will automatically choose the responder depending on the request format:
html
Sylius\Component\Resource\Symfony\Request\State\TwigResponder
json
Sylius\Component\Resource\Symfony\Request\State\ApiResponder
xml
Sylius\Component\Resource\Doctrine\Common\State\ApiResponder
Twig Responder
The Twig responder is used to render data into a Symfony response. It's used for HTML responses.
The variables that are passed to the Twig templates depends on the operation (See Configure your operations chapter).
Customize Twig template variables
Some variables are already available on your operations, but you can add more variables easily.
As an example, we add a foo
variable to the Twig template with bar
as value.
Use it on your operation.
API Responder
The API responder is used to render serialized data into a Symfony response. It's used for JSON/XML responses.
Last updated