FriendsOfSymfony/FOSRestBundle

FOSRest\View group overload when forwarding to controller

flohw opened this issue · 0 comments

flohw commented

Hi!

I notice that when a controller forward its request to another the @FOSRest\View annotation is overloaded by the latest instead of the annotation on the controller which forward the request. I think the good option would be that the forwarding controller should override the latest.

An example to clarify

namespace Backend\Controller;

/**
 * @FOSRest\View(serializerGroups={"backend_list"})
 */
class GetNewsController {
    public function __invoke() {
        return $this->forward(Frontend\Controller\GetNewsController::class);
    }
}

namespace Frontend\Controller;

/**
 * @FOSRest\View(serializerGroups={"frontend_list"})
 */
class GetNewsController {
    public function __invoke() {
        return [];
    }
}

When the Frontend controller is called, the applied serializer groups are those one listed in Backend. Which might be a problem.

I can try to investigate and make a PR if I can get some clues where to search 🙂

Thanks