8000 [Routing] 'host' routes using 'requirements' does not pass through mandatory parameters · Issue #7538 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Routing] 'host' routes using 'requirements' does not pass through mandatory parameters #7538

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

Closed
FunTimeCoding opened this issue Apr 1, 2013 · 10 comments

Comments

@FunTimeCoding
Copy link

So I have this in my app/config/routing.yml:
acme_store_dev:
resource: "@AcmeStoreBundle/Resources/config/routing.yml"
host: acme.{tld}
requirements:
tld: dev|org

and something like this in the bundles routing.yml:
acme_store_homepage:
pattern: /hello/{name}
defaults: { _controller: AcmeStoreBundle:Default:index }
acme_store_product:
resource: "@AcmeStoreBundle/Resources/config/routing/product.yml"
prefix: /product

and the product.yml contains several auto generated routes like that:
product_show:
pattern: /{id}/show
defaults: { _controller: "AcmeStoreBundle:Product:show" }

The problem is within the first configuration. If I only use one host and no tld matching (and any other form of regex matching in hosts) itll lead to this kind of error:

An exception has been thrown during the rendering of a template ("Some mandatory parameters are missing ("tld") to generate a URL for route "category_new".") in AcmeStoreBundle:Category:index.html.twig at line 36.

I could now start rewriting all that the crud generator made for me or stop using that form of host matching, but Id really like to use those two features - any suggestions? is this a bug that can be fixed? from what I understand the /prefix is supposed to map route extensions dynamically, and independent of any prior routes, which is also quite nifty to have.

@Tobion
Copy link
Contributor
Tobion commented Apr 1, 2013

Sorry I read your description like 10 times and still don't understand what you describe. For a bug report please say what the actual behavior is and what the expected behavior is. Also consider using the mailing list for support questions.

@FunTimeCoding
Copy link
Author

if there is no:

host: acme.{tld}
requirements:
tld: dev|org

but instead:

host: acme.dev

it works fine. the problem occurs when using host and requirements together.

@Tobion
Copy link
Contributor
Tobion commented Apr 1, 2013

You have to pass the tld param when generating a route. Just as the exceptions says.
As you probably expect a simpler use, it's a duplicate of #6857.

@Tobion Tobion closed this as completed Apr 1, 2013
@FunTimeCoding
Copy link
Author

does #6857 elaborate on how to pass a parameter when generating a route? Ive read the ticket but Im not sure how to fix that issue.

@Tobion
Copy link
Contributor
Tobion commented Apr 1, 2013

Just as you pass any other parameter when generating a route.

@FunTimeCoding
Copy link
Author

I shall try and find some more documentation on how to do that. thank you.

@FunTimeCoding
Copy link
Author

after further research and discussion on the symfony irc channel I believe that there is no obvious solution by 'passing a parameter', afterall it works for as long as there is no prefix instruction used to pull in more routes (that are generated) - so this must be a bug or an incomplete implementation of the host matching feature. it works with a simplified usecase, but not when using extra routes with prefix.

or am I wrong, and you could give me an example on how to fix this without having to rewrite everything the crud form generator produced?

@Tobion
Copy link
Contributor
Tobion commented Apr 2, 2013

So this is a problem with the crud generator and not really the routing component as you describe in the title.
Remember the crud generator is designed as a base code which you probably want to adjust anyway.
Anyway, #6857 would also fix this issue so still a duplicate.

@bierdok
Copy link
Contributor
bierdok commented Oct 29, 2013

@FunTimeCoding This comment can help you #3965 (comment)

@FunTimeCoding
Copy link
Author

thanks.

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

3 participants
0