Skip to content

Commit

Permalink
bug #365 Fix route loaders (loic425)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.9-dev branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Bug fix?        | yes
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | 
| License         | MIT

Without this interface, the routes are not re-generating on a change without clearing the cache.

Commits
-------

4e69cb2 Fix route loaders
  • Loading branch information
lchrusciel authored Feb 2, 2022
2 parents 6e3e4eb + 4e69cb2 commit 8326f4c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Bundle/Routing/CrudRoutesAttributesLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@

use Sylius\Component\Resource\Annotation\SyliusCrudRoutes;
use Sylius\Component\Resource\Reflection\ClassReflection;
use Symfony\Bundle\FrameworkBundle\Routing\RouteLoaderInterface;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Yaml\Yaml;

final class CrudRoutesAttributesLoader
final class CrudRoutesAttributesLoader implements RouteLoaderInterface
{
private array $mapping;

Expand Down
3 changes: 2 additions & 1 deletion src/Bundle/Routing/RoutesAttributesLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
namespace Sylius\Bundle\ResourceBundle\Routing;

use Sylius\Component\Resource\Reflection\ClassReflection;
use Symfony\Bundle\FrameworkBundle\Routing\RouteLoaderInterface;
use Symfony\Component\Routing\RouteCollection;

final class RoutesAttributesLoader
final class RoutesAttributesLoader implements RouteLoaderInterface
{
private array $mapping;

Expand Down
6 changes: 6 additions & 0 deletions src/Bundle/spec/Routing/CrudRoutesAttributesLoaderSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Sylius\Bundle\ResourceBundle\Routing\RouteFactoryInterface;
use Sylius\Component\Resource\Metadata\MetadataInterface;
use Sylius\Component\Resource\Metadata\RegistryInterface;
use Symfony\Bundle\FrameworkBundle\Routing\RouteLoaderInterface;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
Expand All @@ -39,6 +40,11 @@ function it_is_initializable(): void
$this->shouldHaveType(CrudRoutesAttributesLoader::class);
}

function it_is_a_route_loader(): void
{
$this->shouldImplement(RouteLoaderInterface::class);
}

function it_generates_routes_from_resource(
RegistryInterface $resourceRegistry,
MetadataInterface $metadata,
Expand Down
6 changes: 6 additions & 0 deletions src/Bundle/spec/Routing/RoutesAttributesLoaderSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Prophecy\Argument;
use Sylius\Bundle\ResourceBundle\Routing\RouteAttributesFactoryInterface;
use Sylius\Bundle\ResourceBundle\Routing\RoutesAttributesLoader;
use Symfony\Bundle\FrameworkBundle\Routing\RouteLoaderInterface;
use Symfony\Component\Routing\RouteCollection;

final class RoutesAttributesLoaderSpec extends ObjectBehavior
Expand All @@ -31,6 +32,11 @@ function it_is_initializable(): void
$this->shouldHaveType(RoutesAttributesLoader::class);
}

function it_is_a_route_loader(): void
{
$this->shouldImplement(RouteLoaderInterface::class);
}

function it_generates_routes_from_paths(RouteAttributesFactoryInterface $routeAttributesFactory): void
{
$routeAttributesFactory->createRouteForClass(Argument::type(RouteCollection::class), Argument::type('string'))->shouldBeCalledTimes(13);
Expand Down

0 comments on commit 8326f4c

Please sign in to comment.