jjgarcía
jjgarcía

Reputation: 589

Symfony2 - identify controller loaded

In a URL load 2 controllers, one by the route:

home:
    path:     /
    defaults: { _controller: AppBundle:Default:index }

another one on twig:

{{ render(controller('AppBundle:Default:twig')) }}

I created a http service, with onKernelResponse, and I would like to identify if controller is loaded by route or by twig.

Any idea to resolve it?

Edited

I found 2 diferences in headers:

doesn't appear on controller load by route.

perhaps the solution is on this way?

Upvotes: 1

Views: 39

Answers (1)

jjgarcía
jjgarcía

Reputation: 589

this is the solution

public function onKernelResponse(FilterResponseEvent $event) {

    if($event->isMasterRequest()){
        // here my code
    }
}

Upvotes: 1

Related Questions