Closed mmenozzi closed 8 years ago
I agree with what you suggest.
Assuming that we will only ever have instances of Route
and Generic
in the route tree, then we could safely assume that Generic
nodes can be replaced by Route
nodes and throw an exception if any other node type were found.
One problem we will encounter is how to "replace" the Generic node, as we are also concerned with its children.
Generic
node (e.g. <node-name>.tmp
, create the AutoRoute
node, then migrate the children, then remove the <node-name>.tmp
This work could be done in the AutoRouteManager https://github.com/symfony-cmf/RoutingAuto/blob/1.0.1/AutoRouteManager.php#L60
This should probably be done in the adapter, using a new method replaceRoute
, and the logic called from the AutoRouteManager.
So, please feel free to have a go at this :)
Hi Daniel, Yes you're right, this is a PHPCR adapter issue because in an ORM adatpter we probably wouldn't have this problem. So I think I opened the issue in the wrong place, sorry... Anyway I think that we have not to change the AutoRouteManager implementation nor the AdapterInterface. I think it's sufficent to change the implementation of two methods in the PHPCR adapter:
What do you think?
Yes, that sounds good :) If we use this solution then we should remember to document these new responsiblities in the AdapterInterface
in this library.
@ I don't think it's a new responsibility. It's just a new implementation of the current responsibilities for the PHPCR ODM adapter.
I agree with @WouterJ. I don't see it as a new responsibility of the Adapter. Anyway I'll work on it and I'll come back with a PR (I hope).
@dantleech @WouterJ PR submitted. Let me know what do you think. Thank you!
Assume the following situation.
cmf_routing_auto.yml
as follows:Assume that with this configuration I first create a "News" document whose title is "My News". Assuming also that the routes base path is
/cms/routes
I have the following PHPCR nodes:/cms/routes/news
: this is a node whosephpcr:class
isDoctrine\ODM\PHPCR\Document\Generic
/cms/routes/news/my-news
: this is the AutoRoute node which points to "My News" content documentNow if I want to create a Page whose title is "News" I'll get the following error:
This is because the schema configuration for a Page document whose title is "News" will end in the PHPCR node path
/cms/routes/news
and this node already exists and is an instance ofDoctrine\ODM\PHPCR\Document\Generic
.I think that the RoutingAuto component should treat a
Doctrine\ODM\PHPCR\Document\Generic
node as a "free" route and should replace the generic node with an AutoRoute node that point to the proper content document.What do you think about this? Can I work on a PR on this issue?