Task #2126

Implement sub routes support (routes should be configured globally in one place)

Added by Bastian Waidelich over 6 years ago. Updated almost 5 years ago.

Status:Resolved Start date:2008-11-11
Priority:Must have Due date:
Assigned To:Bastian Waidelich % Done:

100%

Category:Configuration
Target version:TYPO3 Flow Base Distribution - 1.0 alpha 1
Sprint: Has patch:
PHP Version: Complexity:

Description

Routes should be configured globally at one place to avoid complexity and make it possible to disable/change existing routes in new distributions.
Currently every package can define it's own routes which might cause an unmanageable configuration and leads to the problem that the loading order of the packages matter.
TODO:
  • move all existing route definitions to the global Routes.yml file
  • make sure, that FLOW3 ConfigurationManager only loads global Routes
  • allow Packages to suggest Routes or to add Sub Routes (probably not in this release)

Related issues

related to YAML - Feature #2322: Possibility to track filename and line number of a specif... New 2008-12-15
related to TYPO3.Flow - Bug #3433: Routes in packages are overruled by global configuration Resolved 2009-05-24

Associated revisions

Revision ff26a5c3
Added by Bastian Waidelich over 6 years ago

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.

Revision 94fb30d7
Added by Bastian Waidelich about 6 years ago

FLOW3:
  • !!! BREAKING CHANGE !!! F3\FLOW3\Configuration\Manager is now able to load sub routes from packages and merge them with main routes. Resolves #2126 (This needs further testing and some cleanup!)
  • !!! BREAKING CHANGE !!! Routes are not processed in reverse order anymore. Resolves #3441.
  • Query string won't be lowercased anymore by the routing framework. Relates to #2237.
  • Added some missing type hints to F3\FLOW3\Configuration\Manager
  • Improved exception messages in F3\FLOW3\MVC\Web\Routing\Route
    FLOW3 Distribution:
  • !!! BREAKING CHANGE !!! adapted global routes to the changes mentioned above and added subroutes to FLOW3/TYPO3CR packages.

Revision 60a120de
Added by Bastian Waidelich about 6 years ago

FLOW3:
  • !!! BREAKING CHANGE !!! F3\FLOW3\Configuration\Manager is now able to load sub routes from packages and merge them with main routes. Resolves #2126 (This needs further testing and some cleanup!)
  • !!! BREAKING CHANGE !!! Routes are not processed in reverse order anymore. Resolves #3441.
  • Query string won't be lowercased anymore by the routing framework. Relates to #2237.
  • Added some missing type hints to F3\FLOW3\Configuration\Manager
  • Improved exception messages in F3\FLOW3\MVC\Web\Routing\Route
    FLOW3 Distribution:
  • !!! BREAKING CHANGE !!! adapted global routes to the changes mentioned above and added subroutes to FLOW3/TYPO3CR packages.

History

#1 Updated by Bastian Waidelich over 6 years ago

  • Assigned To set to Bastian Waidelich

#2 Updated by Bastian Waidelich over 6 years ago

Additionally Routes should not be configured with a named index to avoid unintended overwriting of routes:

MyRoute1:
  uriPattern: 'foo'
  defaults:
    @package: MyPackage1
MyRoute2:
  uriPattern: 'bar'
  defaults:
    @package: MyPackage2

# this disables previously defined MyRoute1:
MyRoute1:
  uriPattern: 'baz'
  defaults:
    @package: MyPackage3

Instead it should be

-
  uriPattern: 'foo'
  defaults:
    @package: MyPackage1

-
  uriPattern: 'bar'
  defaults:
    @package: MyPackage2

-
  uriPattern: 'baz'
  defaults:
    @package: MyPackage3

For debugging, it will be possible to identify the YAML file and filenumber of a Route's configuration. This relates to #2322

#3 Updated by Karsten Dambekalns over 6 years ago

  • Status changed from New to Accepted

#4 Updated by Karsten Dambekalns over 6 years ago

Bastian and I talked about routing for some hours last Friday (Feb 27th). We had this idea to solve this (Bastian, if I miss something, feel free to fill in):

  • Packages can define "Sub"-Routes in their Routes.yaml
  • TYPO3 by default only reads Routes.yaml from the global configuration space (and context, of course)
  • "Sub"-Routes can be imported/mounted under a prefix in the global configuration
  • the later could also be done through some tool, preferably the package manager, which could also alert the user of existing "sub"-routes (or presets as you might call them)
  • a routing setup tool will allow for display and simulated matching of URIs against the configuration to ease debugging and setup

The syntax with which the "sub"-routes will be like this:

 ---- YAML ----
uriPattern: tools/{TYPO3CR}'
  routeParts:
    TYPO3CR:
      subRoutes:
        package: TYPO3CR
uriPattern: tools/{backupThingie}'
  routeParts:
    backupThingie:
      subRoutes:
        package: SiteBackup
        file: OptimizedRoutes.yaml
 ---- YAML ----

This means that "sub"-routes can be "mounted" with any prefix and will be configured like a route part. If only 'package' is given, Routes.yaml will be used, if 'file' is given a specific set of rules can be imported (this can be given multiple times to allow for modular rulesets, they are then combined).

'file' can not hold a path and is always relative to the package's 'Configuration' directory.

Notes:
  • the naming of the "sub"-routes needs to be finalized :)
  • if you have ideas to share, shoot!

#5 Updated by Robert Lemke about 6 years ago

  • Subject changed from Routes should be configured globally in one place to Implement sub routes support (routes should be configured globally in one place)
  • Priority changed from Should have to Must have

#6 Updated by Bastian Waidelich about 6 years ago

  • Status changed from Accepted to Resolved
  • % Done changed from 0 to 100

Applied in changeset r2381.

#7 Updated by Bastian Waidelich about 6 years ago

The syntax for subRoutes is (as in r2381):

--
  uriPattern: foo/<mySubRoutes>/{bar}
  defaults:
    {bar}: someDefault
  subRoutes:
    mySubRoutes:
      package: MyPackage

Also available in: Atom PDF