Feature #1790
Routing: optional RouteParts
Status: | Resolved | Start date: | 2008-10-23 | |
---|---|---|---|---|
Priority: | Must have | Due date: | ||
Assigned To: | Bastian Waidelich | % Done: | 100% |
|
Category: | MVC | |||
Target version: | TYPO3 Flow Base Distribution - 1.0 alpha 1 | |||
PHP Version: | Complexity: | |||
Has patch: |
Description
We were thinking about a possibility to mark parts of the uriPattern optional. This could look something like:
$c->TYPO3Route_ServiceWithControllerAndFormat ->setUrlPattern('typo3/service/v1/[@controller].[@format](?orderby=[orderby])') ->setControllerComponentNamePattern('F3::@package::Service::Controller::@controllerController') ->setViewComponentNamePattern('F3::@package::Service::View::@controller::@action@format') ->setDefaults( array( '@package' => 'TYPO3', 'orderby' => 'id' ) );
the query part would be optional in this example. This would help to drastically reduce the amount of routes. You could do something like this too:
$c->myRoute ->setUrlPattern('typo3/service/v1/[@controller](.[@format])') ...
to mark the format suffix optional.
We'll have to resolve some logical challenges though.
E.g. we'll have to dissallow routes like this one:
$c->impossibleRoute ->setUrlPattern('static/[dynamic1](optional)[dynamic2]') ...
because the routing mechanismn could not tell where [dynamic1] ends.
Associated revisions
FLOW3:
- improved strategy pattern implementation in DynamicRoutePart to simplify creation of custom RoutePartHandlers.
- parsed URI pattern is not represented as uriPatternSegmentCollection anymore but as simple array of Route Parts making URI matching more flexible and easier to comprehend.
- added Interfaces RoutePartInterface and DynamicRoutePartInterface
- improved error handling for invalid URI patterns. Replaced F3\FLOW3\MVC\Exception\SuccessiveDynamicRouteParts by F3\FLOW3\MVC\Exception\InvalidUriPattern.
- lots of smaller tweaks
- BREAKING CHANGES:
- moved all Routes to global Configuration/Routes.yaml. Addresses #2126.
- dynamic Route Parts are no longer enclosed by square brackets but by curly brackets. Resolves #2342.
- removed support for query strings in URI pattern for now. It increased complexity and wasn't really needed yet.
- added support for optional route parts. Just put the respective parts in brackets in your URI pattern. NOTE: Dynamic Route Parts are no longer optional by default (even if a default value is set). Resolves #1790.
History
#1 Updated by Karsten Dambekalns almost 7 years ago
- Target version deleted (
1.0 alpha 1)
#2 Updated by Karsten Dambekalns almost 7 years ago
- Priority changed from Should have to Must have
- Target version set to 1.0 alpha 1
#3 Updated by Bastian Waidelich over 6 years ago
- % Done changed from 0 to 90
#4 Updated by Bastian Waidelich over 6 years ago
- Status changed from New to Resolved
- % Done changed from 90 to 100
Applied in changeset r1921.