[TYPO3-50-general] Need help with Routing

Bastian Waidelich bastian at typo3.org
Mon Mar 2 21:56:18 CET 2009


Karsten Dambekalns wrote:

> Hi (?:.*)

Expresso* says "(?:)" ->  "Match expression, but don't capture it."
hehe, good one ;)

> (Bastian, if I miss something, feel free to fill in):

you didn't miss anything as far as I can tell, but I'd like to add a few 
things anyway *g

the syntax of the route configuration will change slightly from:

   uriPattern: 'posts/{post}.html'
   defaults:
     @package:    'Blog'
     @controller: 'Posts'
     @action:     'show'
   routePartHandlers:
     post:        'F3\Blog\RoutePartHandlers\PostRoutePartHandler'

to something like:

   uriPattern: 'posts/{post}.html'
   defaults:
     @package:    'Blog'
     @controller: 'Posts'
     @action:     'show'
   routeParts:
     post:
       handler:   'F3\Blog\RoutePartHandlers\PostRoutePartHandler'

That'll allow us to specify additional options for the handler:

   uriPattern: 'posts/{post}.html'
   defaults:
     @package:    'Blog'
     @controller: 'Posts'
     @action:     'show'
   routeParts:
     post:
       handler:   'F3\Blog\RoutePartHandlers\PostRoutePartHandler'
         options:
           caseSensitive: false
           foo: 'bar'


Furthermore this makes it possible to set other route part options 
without bloating the configuration too much. E.g. "subroutes":

   uriPattern: 'blog/{blog}.html'
   defaults:
     @package:    'Blog'
   routeParts:
     post:
       subRoutes:
         package: Blog

a "subroute" looks just like a normal route:

   uriPattern: '{post}'
   defaults:
     @controller: 'Posts'
     @action:     'show'
   routeParts:
     post:
       handler:   'F3\Blog\RoutePartHandlers\PostRoutePartHandler'


   uriPattern: 'setup'
   defaults:
     @controller: 'Setup'
     @action:     'index'


Internally, the router would resolve the subroutes by generating the 
composite routes:

   uriPattern: 'blog/{post}.html'
   defaults:
     @package:    'Blog'
     @controller: 'Posts'
     @action:     'show'
   routeParts:
     post:
       handler:   'F3\Blog\RoutePartHandlers\PostRoutePartHandler'

and

   uriPattern: 'blog/setup.html'
   defaults:
     @package:    'Blog'
     @controller: 'Setup'
     @action:     'index'

(Well, it doesn't actually write YAML code obviously, but combines the 
routes under the hood during parsing of the routes configuration)

Issues that are most blurry for me at the moment are:

- the exact syntax for the inclusion of subroutes. I'd like to have 
something like "EXT:myext/myfile" in FLOW3. Any plans yet?

- "namespacing" of route part values (like "tx_myext[key]" in TYPO3v4).

- how is the priority of defaults and route parts. In other words, can a 
subroute overwrite values from its "parent" route?


feedback wanted ;)
Bastian

-- 
* Expresso is a great RegEx tool: http://www.ultrapico.com/Expresso.htm 
(only Windows though, I'm afraid)


More information about the TYPO3-project-5_0-general mailing list