symfony-cmf / routing-auto

RoutingAuto component
https://cmf.symfony.com
Other
6 stars 11 forks source link

[REJECTED] Support for Host schema, route options and http schemes #22

Closed dantleech closed 9 years ago

dantleech commented 9 years ago

tl;dr; I don't think this is a good idea, and we should implement an event dispatcher instead.

This PR is In reponse to the PR https://github.com/symfony-cmf/RoutingAuto/pull/21 which adds support for mapping arbitrary values to route methods, which aims to solve the issue https://github.com/symfony-cmf/RoutingAutoBundle/pull/139

This PR adds support for adding a host, schemes [ http, https ], and route options to the routing auto configuration:

foobar:
   uri_schema: bar/foo
   host_schema: sub.{domain}.com
   token_providers:
       domain: [ content_method, {method: 'getDomain'} ]
   allowed_schemes: [ https ]
   route_options:
       custom_option: one
       custom_option: two

All of the above options can be mapped directly to Symfonys Route object.

There are problems however with the host_schema:

And, for all that I do not think it good practice to store the host name in the route, neither in PHPCR or in an ORM. This is breaking the DRY rule.

The host name would be better placed (in PHPCR) as part of the path, and in an ORM as an ID refering to some Host table.

Saying that, storing the host or anyother attribute in the Route document could be easily facilitated if we implement an EventDispatcher.

So basically, I suggest that we forget about this for now and instead implement an Event Dispatcher and a cmf_routing_auto.post_auto_route event or some-such.

p.s. If we implement the Event Dispatcher then the conflcit resolver would still need to be aware of the host property of routes, which I think would be a harmless addition.

dantleech commented 9 years ago

/cc @WouterJ

dbu commented 9 years ago

+1 for events. maybe even pre and post generating the path according to the rules. so that i can either skip generating and do my custom thing, or prepare some things for the automatic things. and in the post i can still alter what the automatics did and i.e. add something fancy.

the post event should be before the duplicate check (or maybe carry information if this is going to be a duplicate, but not yet alter the url to deduplicate)

dantleech commented 9 years ago

Have created https://github.com/symfony-cmf/RoutingAuto/pull/23 to add an EventDispatcher and an event, so that makes it possible to do these things.

dantleech commented 9 years ago

Closing

dantleech commented 9 years ago

wtf