FriendsOfSymfony / FOSJsRoutingBundle

A pretty nice way to expose your Symfony routing to client applications.
1.48k stars 260 forks source link

Define RoutesResponse as a Service #474

Closed pyksid closed 5 months ago

pyksid commented 6 months ago

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
    {
        [...]
    }
tobias-93 commented 5 months ago

Thanks @pyksid