Skip to content

Commit

Permalink
Use abstract loader from Symfony
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 committed May 29, 2024
1 parent 8d2e528 commit 9ea6acd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/Bundle/Resources/config/services/routing.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<argument type="service">
<service class="Sylius\Bundle\ResourceBundle\Routing\RouteFactory" />
</argument>
<argument>%kernel.environment%</argument>
<tag name="routing.loader" />
</service>
<service id="Sylius\Bundle\ResourceBundle\Routing\ResourceLoader" alias="sylius.routing.loader.resource" public="false" />
Expand Down
25 changes: 8 additions & 17 deletions src/Bundle/Routing/ResourceLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 9ea6acd

Please sign in to comment.