Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

support routes stored in Doctrine ORM #19

Open
ghost opened this issue Apr 28, 2013 · 11 comments
Open

support routes stored in Doctrine ORM #19

ghost opened this issue Apr 28, 2013 · 11 comments

Comments

@ghost
Copy link

ghost commented Apr 28, 2013

This would go along with symfony-cmf/routing-bundle#83 if it happens.

@dantleech
Copy link
Member

Yes, I was thinking about this and it should be quite straight forward.

  • Create an abstraction class for database interaction (i.e. a driver for each persistance backend or some Manager class with all the features needed by the various path prodivders and actions)
  • Create a listener for each persistence backend

This would be a good place to try out some new namespacing too:

/../Persistence/Doctrine/PHPCR/EventListener/Listener.php
/../Persistence/Doctrine/PHPCR/Document/AutoRoute.php
/../Persistence/Doctrine/PHPCR/Driver/PHPCRDriver.php
/../Persistence/Doctrine/ORM/EventListener/Listener.php
/../Persistence/Doctrine/ORM/Document/AutoRoute.php
/../Persistence/Doctrine/ORM/Driver/PHPCRDriver.php

/@cc @dbu

@dbu
Copy link
Member

dbu commented Apr 29, 2013

regarding the namespacing part: yes. but we should only create persistence specific model classes if really needed. see also FriendsOfSymfony/FOSUserBundle#1081 where i try to get rid of the classes in Entity/Document completely. the same btw for listener, if its just doctrine specific it could live in Persistence/Doctrine/EventListener directly.

@steve-todorov
Copy link

@dantleech @dbu ping? I see this has already been implemented into the RoutingBundle (PR 122). Would it be a lot of work to implement it here as well? I'm currently researching the whole Symfony CMF project (including the dynamic routings). If you could give me some guidance I could try to implement it?

@dantleech
Copy link
Member

No it shouldn't be alot of work. We just need implement a new Adapter and a new subscriber.

@wouterj
Copy link
Member

wouterj commented Sep 13, 2015

The difficult thing here is the relation with the content entity. Should we implement this with 2 queries? (one query only getting the AutoRoute and the other the related content, saving both content type and id in the OrmAutoRoute?)

@fredpeaks
Copy link

Is there any news about the ORM support ?

@dantleech
Copy link
Member

@fredpeaks I plan to get this into the 2.0 release. I imagine the work to be as follows:

@fredpeaks
Copy link

@dantleech Thank you for the answer, great news !
Do you have some indication on the period where the 2.0 could be released ? I know this can be a tricky question...

@dantleech
Copy link
Member

Not really. It is next on my list, but it could be a month or two before its started/finished, feel free to start on it if you like however.

@fredpeaks
Copy link

Ok thanks. I will try to start this based on your PR.

@fredpeaks
Copy link

For information I've been working on this and the RoutingBundle ORM integration. I've managed to make things work but I've no time for now to finish and create a pull request (there are a lot of tests to write, documentation, refactoring eventually...). I already use this on a real project (under development). It'working but not fully tested yet.

If you want to have a look at what I've done, here are the repos :
https://github.com/fredpeaks/RoutingBundle
https://github.com/fredpeaks/RoutingAutoBundle

A quick list of added functionalities:

  • content entity can be attached to Orm Route in RoutingBundle (largely inspired by RaindropRoutingBundle and necessary for AutoRouting)
  • ORM RedirectRoute
  • add ORM admin for routes
  • change doctrine mapping and classes hierarchy to allow usage of tables inheritance and RoutingAutoBundle to create entity mapping instead of RoutingBundle (adding AutoRoute Entity).
  • ORM autoroutes

I've been forced to make design choices and there is a lot to discuss about the way things are done.
I've tried to minimize code duplication but the way Doctrine inheritance works forced me to have some. For example the Orm RedirectRoute class cannot inherit the Model RedirectRoute class because it has to inherit the Orm Route class in order to be able to implement Doctrine Orm inheritance. Same for AutoRoute class. Maybe someone will come with a better solution.

I'll try to make a pull request next week and write a detailed description.

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

No branches or pull requests

5 participants