From 9ea6acdc516793988f238613f2d3b18d86d7c85e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Fr=C3=A9mont?= Date: Wed, 29 May 2024 15:31:33 +0200 Subject: [PATCH] Use abstract loader from Symfony --- .../Resources/config/services/routing.xml | 1 + src/Bundle/Routing/ResourceLoader.php | 25 ++++++------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/Bundle/Resources/config/services/routing.xml b/src/Bundle/Resources/config/services/routing.xml index a84844b94..58adb37f4 100644 --- a/src/Bundle/Resources/config/services/routing.xml +++ b/src/Bundle/Resources/config/services/routing.xml @@ -20,6 +20,7 @@ + %kernel.environment% diff --git a/src/Bundle/Routing/ResourceLoader.php b/src/Bundle/Routing/ResourceLoader.php index e54793a8e..859c0c13e 100644 --- a/src/Bundle/Routing/ResourceLoader.php +++ b/src/Bundle/Routing/ResourceLoader.php @@ -17,22 +17,26 @@ use Sylius\Resource\Metadata\MetadataInterface; use Sylius\Resource\Metadata\RegistryInterface; use Symfony\Component\Config\Definition\Processor; +use Symfony\Component\Config\Loader\Loader; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Config\Loader\LoaderResolverInterface; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Yaml\Yaml; -final class ResourceLoader implements LoaderInterface +final class ResourceLoader extends Loader { private RegistryInterface $resourceRegistry; private RouteFactoryInterface $routeFactory; - private LoaderResolverInterface $resolver; + public function __construct( + RegistryInterface $resourceRegistry, + RouteFactoryInterface $routeFactory, + ?string $env, + ) { + parent::__construct($env); - public function __construct(RegistryInterface $resourceRegistry, RouteFactoryInterface $routeFactory) - { $this->resourceRegistry = $resourceRegistry; $this->routeFactory = $routeFactory; } @@ -105,19 +109,6 @@ public function supports($resource, $type = null): bool return 'sylius.resource' === $type || 'sylius.resource_api' === $type; } - /** - * @psalm-suppress InvalidReturnType Symfony docblocks are messing with us - */ - public function getResolver(): LoaderResolverInterface - { - return $this->resolver; - } - - public function setResolver(LoaderResolverInterface $resolver): void - { - $this->resolver = $resolver; - } - private function createRoute( MetadataInterface $metadata, array $configuration,