Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with routing when we make a mistake in our own app #75

Open
jacquesbh opened this issue May 8, 2019 · 2 comments
Open

Issue with routing when we make a mistake in our own app #75

jacquesbh opened this issue May 8, 2019 · 2 comments

Comments

@jacquesbh
Copy link

jacquesbh commented May 8, 2019

Hi!

In your routing you have:

sylius_sitemap_providers:
    resource: .
    type: sitemap

This causes a problem when we make a mistake in our own routing. If so, it returns always this error:

Exception thrown when handling an exception (Symfony\Component\Config\Exception\LoaderLoadException: Do not add the "sitemap" loader twice in . (which is being imported from "/sylius/vendor/stefandoorn/sitemap-plugin/src/Resources/config/routing.yml"). Make sure there is a loader supporting the "sitemap" type.)

If we comment out the route configuration above, we get the correct error: (as example, in my case)

Exception thrown when handling an exception (Symfony\Component\Config\Exception\LoaderLoadException: The routing file "/sylius/config/routes.yaml" must not specify both the "resource" key and the "path" key for "app_custom". Choose between an import and a route definition in /sylius/config/routes.yaml (which is loaded in resource "/sylius/config/routes.yaml").)

And this is the same issue everytime we make an error in our config.
This is kind of very annoying actually.

Can we try to find a solution to avoid this behavior?
What do you think?

Thanks!

How to reproduce

Of course with the sitemap bundle loaded.

In your config/routes.yaml, add these lines:

example:
    resource: "toto.yaml"

Do not create the toto.yaml file.

Reload and you'll get the error …Do not add the "sitemap" loader twice in….

Now, comment the lines in the routing of the bundle like written above in the description.
Reload and you get this error: …The file "toto.yaml" does not exist…

This is much better don't you think?
Thanks!

@stefandoorn
Copy link
Owner

Thanks @jacquesbh. I've been looking through this, but I find it hard to figure out what is the issue here. I've also reverted to the Symfony docs, and basically it's following the suggestions there: https://symfony.com/doc/current/routing/custom_route_loader.html#using-the-custom-loader. I'm a bit lost where the error is coming from therefore.

@stefandoorn
Copy link
Owner

@jacquesbh Could you try removing the Exception and letting it load twice? I'm curious what happens to the routing table and performance if the router get's executed twice. Alternative is to see in case it's already loaded, to just return an empty RouteCollection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants