public function onKernelResponse(FilterResponseEvent $event)
    {
        $request = $event->getRequest();
        $routeName = $request->attributes->get('_route');
        if (!$route = $this->app['routes']->get($routeName)) {
            return;
        }

        foreach ((array) $route->getOption('_after_middlewares') as $callback) {
            $response = call_user_func($this->app['callback_resolver']->resolveCallback($callback), $request, $event->getResponse(), $this->app);
            if ($response instanceof Response) {
                $event->setResponse($response);
            } elseif (null !== $response) {
                throw new \RuntimeException(sprintf('An after middleware for route "%s" returned an invalid response value. Must return null or an instance of Response.', $routeName));
            }
        }
    }
public function onKernelResponse(FilterResponseEvent $event)
    {
        $request = $event->getRequest();
        $routeName = $request->attributes->get('_route');
        if (!$route = $this->app['routes']->get($routeName)) {
            return;
        }

        foreach ((array) $route->getOption('_after_middlewares') as $callback) {
            $response = call_user_func($this->app['callback_resolver']->resolveCallback($callback), $request, $event->getResponse(), $this->app);
            if ($response instanceof Response) {
                $event->setResponse($response);
            } elseif (null !== $response) {
                throw new \RuntimeException(sprintf('An after middleware for route "%s" returned an invalid response value. Must return null or an instance of Response.', $routeName));
            }
        }
    }
public function onKernelResponse ( FilterResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; $ routeName = $ request -> attributes -> get ( '_route' ) ; if ( ! $ route = $ this -> app [ 'routes' ] -> get ( $ routeName ) ) { return ; } foreach ( ( array ) $ route -> getOption ( '_after_middlewares' ) as $ callback ) { $ response = call_user_func ( $ this -> app [ 'callback_resolver' ] -> resolveCallback ( $ callback ) , $ request , $ event -> getResponse ( ) , $ this -> app ) ; if ( $ response instanceof Response ) { $ event -> setResponse ( $ response ) ; } elseif ( null !== $ response ) { throw new \ RuntimeException ( sprintf ( 'An after middleware for route "%s" returned an invalid response value. Must return null or an instance of Response.' , $ routeName ) ) ; } } }
Runs after filters.

@param FilterResponseEvent $event The event to handle
Runs after filters .