[TYPO3-50-general] Need help with Routing

Christoph Blömer chbloemer at gmx.net
Mon Feb 16 23:56:31 CET 2009


Bastian Waidelich schrieb:
> Christoph Blömer wrote:
>
> Hi Christoph,
>
> I've finally committed the Routing changes as you can read in the most 
> current thread.
> With the current architecture it's quite easy to achieve what you need:
>
> Let's say you have a package "WebDAV". Just create a subfolder 
> "RoutePartHandlers" and the WebDAVRoutePartHandler.php:
>
> declare(ENCODING = 'utf-8');
> namespace F3\WebDAV\RoutePartHandler;
>
> class WebDAVRoutePartHandler extends 
> \F3\FLOW3\MVC\Web\Routing\DynamicRoutePart {
>
> 	protected function findValueToMatch($requestPath) {
> 		return $requestPath;
> 	}
> }
>
> And than add a Route at the end of the global Routes.yaml:
>
> WebDAV:
>    uriPattern: 'webdav/{path}'
>    defaults:
>      @package:    'WebDAV'
>      @controller: 'Default'
>      @action:     'index'
>    routePartHandlers:
>      path: 'F3\WebDAV\RoutePartHandler\WebDAVRoutePartHandler'
>
>   
I also had to add
  controllerObjectNamePattern: F3\WebDAV\Controller\DefaultController
otherwise it didn't work.
> if you want the path to be optional, it should be something like:
>
> WebDAV:
>    uriPattern: 'webdav(/{path})'
>    defaults:
>      @package:    'WebDAV'
>      @controller: 'Default'
>      @action:     'index'
>      path:        '/'
>    routePartHandlers:
>      path: 'F3\WebDAV\RoutePartHandler\WebDAVRoutePartHandler'
>
>
> Obviously the RoutePartHandler above is not really WebDAV-related. All 
> it does is storing the part of the request Path that haven't been 
> matched yet.
> But you could easily improve it. Just have a look at the parent Class 
>   
Thanks a lot. It's working how I expect it to work.
But it would be nice to define that as local routes.

Maybe localroutes are deactivated by default and you can active them by 
adding one line of code to the global routes configuration.
Or something like:

WebDAV:
    uriPattern: 'webdav'
    routesConfig: 'WebDAV/Configuration/Routes.yaml'

And for TYPO3 it would be later:

TYPO3:
    uriPattern: ''
    routesConfig: 'TYPO3/Configuration/Routes.yaml'

LocalRoutes are then only allowed on the uriPattern "webdav"
In the local Routes.yaml u only need to write

   uriPattern: '(/{path})'

So local routes would be relative to the uri pattern defined in the global routes config or the packageKey as the uriPattern.

for example:
http://localhost/webdav/Ordner1/Unterordner1 (webdav needs to be defined in the global routes because the package key is WebDAV)
or 
http://localhost/WebDAV/Ordner1/Unterordner1 (WebDAV is automatically defined because it's the package key)

These are just some ideas to prevent conflicts between localroutes from other packages.
And if there would be some conflicts somehow, you could add a priority argument maybe.

What do you think?

Greetings
Christoph

p.s: the automatic route could be
Default:
    uriPattern: '@package'
    routesConfig: '@package/Configuration/Routes.yaml'



> DynamicRoutePart. And don't hesitate to post if you have further questions!
>   
> good luck,
> Bastian
> _______________________________________________
> TYPO3-project-5_0-general mailing list
> TYPO3-project-5_0-general at lists.netfielders.de
> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-project-5_0-general
>
>   



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