Laravel检查管线是否使用宏

Laravel检查管线是否使用宏,laravel,routes,router,Laravel,Routes,Router,无法确定哪些路由使用宏 我已经在我的应用程序服务提供商中注册了一个宏,并在一些路线上使用了它。我想看看哪些路由使用这个已注册的宏。当我在任何路由上调用hasMacro时,无论路由是否使用它,它在所有路由上都返回true 文档中说,如果宏已注册,hasMacro方法将返回true,这解释了为什么所有路由都返回true 文件: 有没有办法确定管线是否使用自定义宏?我很乐意在调用此宏时更改组、名称空间或中间件,然后查询该宏,但到目前为止还无法做到这一点。有什么建议吗 Route::macro('gra

无法确定哪些路由使用宏

我已经在我的应用程序服务提供商中注册了一个宏,并在一些路线上使用了它。我想看看哪些路由使用这个已注册的宏。当我在任何路由上调用hasMacro时,无论路由是否使用它,它在所有路由上都返回true

文档中说,如果宏已注册,hasMacro方法将返回true,这解释了为什么所有路由都返回true

文件:

有没有办法确定管线是否使用自定义宏?我很乐意在调用此宏时更改组、名称空间或中间件,然后查询该宏,但到目前为止还无法做到这一点。有什么建议吗

Route::macro('graphQL', function ($type = 'query', $isList = true) {
            if (!in_array($type, ['query', 'mutation'])) throw new InvalidGraphQLTypeException();

            // throw new GraphQLControllerMethodException("This route is for a GraphQL endpoint and can not be accessed.");
        });

啊哈!简单的解决方案。在宏中,只需设置一个属性,然后检查该属性

Route::macro('graphQL', function ($type = 'query', $isList = true) {
            if (!in_array($type, ['query', 'mutation'])) throw new InvalidGraphQLTypeException();

            $this->graphQl = true;

            return $this;

            // throw new GraphQLControllerMethodException("This route is for a GraphQL endpoint and can not be accessed.");
        });

啊哈!简单的解决方案。在宏中,只需设置一个属性,然后检查该属性

Route::macro('graphQL', function ($type = 'query', $isList = true) {
            if (!in_array($type, ['query', 'mutation'])) throw new InvalidGraphQLTypeException();

            $this->graphQl = true;

            return $this;

            // throw new GraphQLControllerMethodException("This route is for a GraphQL endpoint and can not be accessed.");
        });
$graphQlRoutes = collect(Router::getRoutes())->filter(function($route) {
            return isset($route->graphQl) && $route->graphQl;
        });