Open dantleech opened 10 years ago
@nicolas-bastien for your use case would using the content_change
strategy (basically being able to select a strategy to employ when the content of a route is changed) solve your use case?
Is there a reason why you cannot use the full RoutingAutoBundle implementation?
@nicolas-bastien how is your form widget to generate the route exactly working? could we bring that as far upstream as possible (either into sonata admin, but maybe even as a form type provided by RoutingAutoBundle)? it would be a very valueable addition.
your simple case (specify the last part of the url) could be integrated with the routing auto bundle.
the other case of editing the full url is probably more tricky, but maybe you could use the routing auto bundle to make the suggested path, and to autocreate missing pieces in the route according to its logic. how do you currently do that? does it depend on the url of the currently selected parent? RoutingAutoBundle has a rich configuration for how to generate the missing parents, which would add flexibility and spare you reinventing that wheel one bit at a time.
Actually, specifying the entire URL from a text field is easy with RoutingAutoBundle - you would just need to setup a content_path provider which gets the path from a method on the Document (which can be a text field and which can thus be edited from a form)
hm, is there a way we could keep the field out of the content document? would feel a bit strange to have a text field with the desired url that is only used by RoutingAutoBundle. a custom form type should be able to handle that i think. @nicolas-bastien how are you currently doing that?
Hi thanks for your answers !
I did my developments with my custom page and have a custom listener and a RouteManager which handle route creation + update for a page.
I have a relative and absolute url mode + more needs in the future to add parameters....
So urls are not stored in my pages, I use the route directly.
@dantleech I don't get why I need to add routing auto bundle as the real need behind is to create a redirect when a route is moved. This is a global routing issue ?
For my part I already have the code : https://github.com/prestaconcept/PrestaCMSCoreBundle/blob/master/Model/RouteManager.php
L313 : generateRedirects methods
It only fails because of UoW process.
So my problem is the same as @dantleech one : https://github.com/symfony-cmf/RoutingAutoBundle/pull/37#issuecomment-29129263
@nicolas-bastien I guess I am asking if RoutingAuto could replace your custom implementation - and then you would get the Redirects for free - but the change I am suggesting here would enable you to automatically create a RedirectRoute when the content linked to a route changes.
I understand but for me at the moment it will be faster to uncomment my //return; in my method as I already did all the job before you did RoutingAutoBundle.
I just miss the correction of UoW like you said in your comment.
Do you know when it can be changed ?
we said that fixing the UoW to allow this scenario is more complicated, so the plan is to have a listener that records url changes and on postFlush creates the redirect routes and does another flush.
automatically creating redirect routes when moving routes is a kind of auto-generating routes, so i think it fits well into this bundle. it would be great if we manage to make this work here and you could use that bundle (even if you do not use the functionality to autogenerate urls for new documents, but only to generate redirects.)
ok understood
Allow the on_content_change strategy to be applied to route classes for which the RoutingAuto bundle doesn't build the routes automatically.