zendframework / zend-router

Standalone routing implementation for HTTP and console requests
BSD 3-Clause "New" or "Revised" License
32 stars 20 forks source link

Empty route type #45

Closed carnage closed 6 years ago

carnage commented 6 years ago

I've been trying to produce a module which has flexible routing which an end user of the module can adapt to fit it into their site. I have hit an impasse being able to fully support the following use cases:

1a. Deploy the module as a stand alone application with the module based at the root of the domain. 1b. Deploy the module as a part of another application with the module based at the root of the domain.

  1. Deploy the module as part of another application with the module based in a "subdirectory" eg prefix the url with a fixed string.
  2. Deploy the module as part of another application with the module based on a different sub domain (at it's root)

For all the cases, the routing structure as used by the module cannot change as it needs to be able to perform redirects and render urls based on the routing. At best I've managed to produce a configuration which solves 2 of the 3.

My attempts to solve it provide a tree of routes anchored by a single route. For customisation, the intention is that the user can replace this route configuration (using standard ZF2 module config) with their own configuration which enables one of the three behaviours. However at present there does not seem to be a way to provide a placeholder route which will allow for (1) which can be replaced to enable (2) + (3) without also changing the child route structure (and thus breaking rendering and redirects)

The solution that I'm proposing is to create a new "Empty" route type which will always return true when asked if it matches and when composed into a route will render as an empty string. This will act as the placeholder route in the above situation and can be swapped to either a segment or domain route type depending on the user needs.

See https://github.com/conferencetools/tickets-module/issues/100 for more info

carnage commented 6 years ago

Fixed in #50