Define Response\RoutesResponse as a Service allows to override and decorate it, to modify the returned routes for the specific needs of its web app.
It allows then to modify the getRoutes() function with a Decorator for example:
<?php
namespace App\Decorator;
use FOS\JsRoutingBundle\Response\RoutesResponse;
use Symfony\Component\DependencyInjection\Attribute\AsDecorator;
#[AsDecorator(decorates: 'fos_js_routing.routes_response')]
class RoutesResponseDecorator extends RoutesResponse
{
public function getRoutes(): array
{
[...]
}
Define
Response\RoutesResponse
as a Service allows to override and decorate it, to modify the returned routes for the specific needs of its web app.It allows then to modify the getRoutes() function with a Decorator for example: