From d7334790f238039c96e226d5877ff10d2a413c7a Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Fri, 13 Sep 2024 12:02:04 +1200 Subject: [PATCH] API Use Symfony's Path class --- src/Controller.php | 6 +++--- src/GraphQLSchemaInitTask.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Controller.php b/src/Controller.php index f5466f3..8069314 100644 --- a/src/Controller.php +++ b/src/Controller.php @@ -8,10 +8,10 @@ use SilverStripe\Control\Director; use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Injector\InjectorNotFoundException; -use SilverStripe\Core\Path; use SilverStripe\GraphQL\Schema\Schema; use SilverStripe\Security\SecurityToken; use SilverStripe\View\Requirements; +use Symfony\Component\Filesystem\Path; class Controller extends BaseController { @@ -127,7 +127,7 @@ protected function findAvailableRoutes($schemas = []): array $explicitSchema = $controllerInfo['Schema'] ?? null; if ($explicitSchema) { if ($schemas === '*' || in_array($explicitSchema, $schemas ?? [])) { - $routes[$explicitSchema] = Path::normalise($pattern, true); + $routes[$explicitSchema] = trim(Path::normalize($pattern), '/'); } continue; } @@ -138,7 +138,7 @@ protected function findAvailableRoutes($schemas = []): array ? $routeController->getSchemaKey() : $routeController->getManager()->getSchemaKey(); if ($schemas === '*' || in_array($schemaKey, $schemas ?? [])) { - $routes[$schemaKey] = Path::normalise($pattern, true); + $routes[$schemaKey] = trim(Path::normalize($pattern), '/'); } } } catch (InjectorNotFoundException $ex) { diff --git a/src/GraphQLSchemaInitTask.php b/src/GraphQLSchemaInitTask.php index c074586..22563ac 100644 --- a/src/GraphQLSchemaInitTask.php +++ b/src/GraphQLSchemaInitTask.php @@ -5,9 +5,9 @@ use SilverStripe\Control\Director; use SilverStripe\Control\HTTPRequest; use SilverStripe\Core\Manifest\ModuleManifest; -use SilverStripe\Core\Path; use SilverStripe\Dev\BuildTask; use SilverStripe\GraphQL\Config\Configuration; +use Symfony\Component\Filesystem\Path; /** * A task that initialises a GraphQL 4+ schema with boilerplate config and files. @@ -138,7 +138,7 @@ class: SilverStripe\GraphQL\Controller SilverStripe\Control\Director: rules: $rules - + SilverStripe\GraphQL\Schema\Schema: schemas: $this->schemaName: