Kunstmaan / KunstmaanBundlesCMS

An advanced yet user-friendly content management system, based on the full stack Symfony framework combined with a whole host of community bundles. It provides a full featured, multi-language CMS system with an innovative page and form assembling process, versioning, workflow, translation and media managers and much more.
https://kunstmaancms.be
MIT License
402 stars 186 forks source link

_slug route #1149

Closed w3q closed 8 years ago

w3q commented 8 years ago

Hello, I'm trying to merge my code into kunstmaan CMS and i have found one issue, maybe you will know how to resolve that.

The thing is that i've implemented some routing from my existing bundles that I've brought to Kunstmaan cms. Now, when I'm trying to hit the homepage /, it will get error: Unable to generate a URL for the named route "_slug" as such route does not exist.

This happens because the default controller does this: return new RedirectResponse($this->generateUrl('_slug', array('url'=>'', '_locale'=>$this->container->getParameter('locale'))));

I have not been able to find out how this is redirected to correct route, since i did not found any route named _slug. How does this work?

mlebkowski commented 8 years ago

It’s defined in a custom router: SlugRouter

w3q commented 8 years ago

I see, but why it symphony throwing me error that it can not find a route then?

w3q commented 8 years ago

Has anyone an idea what it can be ? I guess the SlugRouter function to add a route will not be called and so it will not add the route, but I don't know why.

Numkil commented 8 years ago

Can you not inject the Kunstmaan SlugRouter in your code and use that to generate your url? That way you would be guaranteed to have the '_slug' url defined.

w3q commented 8 years ago

What exactly do you mean by that? It stopped functioning and I have no idea why. I'm trying to get it working, but have no idea why it is not called to add a route.

Numkil commented 8 years ago

Your code probably overrides the router used by the defaultcontroller so it does not actually use the Kunstmaan SlugRouter. Which is why the '_slug' route is not defined. But I'm just guessing now. Do you have the code somewhere public so I could take a look at it and try to give a more educated answer?

w3q commented 8 years ago

Actually, we have been able to figure it out just few minutes ago. The thing was exactly what you have said. We just changed the order of routers and it is okay now.

Thank you.

Numkil commented 8 years ago

Happy to have been helpful :) Would you be so kind as to close this issue then? thanks.