protected function getRouteFromRequest(Request $request)
    {
        $attributes = $request->attributes->get('_route_params');

        if (isset($attributes[RouteObjectInterface::ROUTE_OBJECT])
            && ($attributes[RouteObjectInterface::ROUTE_OBJECT] instanceof RouteInterface)
        ) {
            return $attributes[RouteObjectInterface::ROUTE_OBJECT];
        }

        return null;
    }