Feature #8736
Implement generic Identity RoutePartHandler
Added by Bastian Waidelich almost 12 years ago.
Updated over 10 years ago.
Description
We should provide a generic RoutePart handler, that allows to match/resolve Identities. This should be configurable through the "options" setting that was implemented with #2825.
Instead of
uriPattern: 'posts/{post}'
defaults:
'@package': Blog
'@controller': Post
'@action': show
routeParts:
post:
handler: F3\Blog\RoutePartHandlers\PostRoutePartHandler
I could imagine something like
uriPattern: 'posts/{post}'
defaults:
'@package': Blog
'@controller': Post
'@action': show
routeParts:
post:
handler: IdentityRoutePartHandler
options:
model: F3\Blog\Domain\Model\Post
pattern: '{date}/{title}'
Then you wouldn't need a custom RoutePart handler anymore most cases..
Note1: the namespace of the handler can be omitted when it is in the FLOW3 package
Note2: the line "handler: IdentityRoutePartHandler" could be implicit for domain models
Note3: how to handle the date format here? should we somehow support regular expressions in the pattern?
- Due date deleted (
2009-03-16)
- Start date deleted (
2009-03-12)
- % Done changed from 100 to 0
- Estimated time changed from 2.00 h to 4.00 h
- Status changed from New to Needs Feedback
One more addition:
According to "Convention over Configuration" the above example could be
uriPattern: 'posts/{post}'
defaults:
'@package': Blog
'@controller': Post
'@action': show
routeParts:
post:
options:
pattern: '{date}/{title}'
-> By default FLOW3s IdentityRoutePart would be used for the domain model. And - if not specified - the model would be @package\Domain\Model\ and uppercase RoutePart-getName(). Would that work?
IMO even the routParts configuration could be ommited - then all @identity properties would be used to build the Uri segments..
What do you think?
- Subject changed from Routing: Implement generic Identity RoutePartHandler to Implement generic Identity RoutePartHandler
- Category changed from MVC to MVC - Routing
I like the concept. As for date formatting, this needs to be configurable. Since the handler could find out about the types of the properties used, it could look for type-specific information in the pattern. E.g. like this:
uriPattern: 'posts/{post}'
defaults:
'@package': Blog
'@controller': Post
'@action': show
routeParts:
post:
options:
pattern: '{date format:Y-m-d}/{title}'
Then it could use
format
as needed.
Karsten Dambekalns wrote:
As for date formatting, this needs to be configurable.
Yes, but I'm unhappy about yet another syntax
{date format:Y-m-d}
Why hasn't the DateTime object more getters.. Then one could write
pattern: '{date.year}-{date.month}-{date.day}/{title}'
And this is not the only case where this was useful..
Maybe we can use our own DateTime implementation in FLOW3!?
Bastian Waidelich wrote:
Yes, but I'm unhappy about yet another syntax
[...]
Why hasn't the DateTime object more getters.. Then one could write
So, in the pattern one could use the object path syntax as in Fluid. Nice idea.
Maybe we can use our own DateTime implementation in FLOW3!?
Yeah, one more reason to have one...
- Status changed from Needs Feedback to Accepted
- Target version set to 1.0 beta 1
- % Done changed from 0 to 30
- Estimated time deleted (
4.00 h)
- Target version changed from 1.0 beta 1 to 1.0 beta 2
- Target version changed from 1.0 beta 2 to 1.0.0
- Status changed from Accepted to Under Review
Patch set 1 of change I8fb5d4f4be3649e2f6307f83af2f3bbaa2191b5b has been pushed to the review server.
It is available at http://review.typo3.org/5076
FYI: The current implementation supports following syntax:
-
name: 'Single Post Actions'
uriPattern: 'posts/{post}(/{@action})'
defaults:
'@package': 'TYPO3.Blog'
'@controller': 'Post'
'@action': 'show'
'@format': 'html'
routeParts:
post:
objectType: TYPO3\Blog\Domain\Model\Post
By default the @identity property/ies of the specified object type are used to create the URI section, or - if they're not specified - the technical identifier (UUID) of the respective object.
Alternatively a custom URI pattern can be specified:
-
name: 'Single Post Actions'
uriPattern: 'posts/{post}(/{@action})'
defaults:
'@package': 'TYPO3.Blog'
'@controller': 'Post'
'@action': 'show'
'@format': 'html'
routeParts:
post:
objectType: TYPO3\Blog\Domain\Model\Post
uriPattern: '{date:Y}/{date:m}/{date:d}/{title}'
Patch set 2 of change I8fb5d4f4be3649e2f6307f83af2f3bbaa2191b5b has been pushed to the review server.
It is available at http://review.typo3.org/5076
Patch set 3 of change I8fb5d4f4be3649e2f6307f83af2f3bbaa2191b5b has been pushed to the review server.
It is available at http://review.typo3.org/5076
Patch set 4 of change I8fb5d4f4be3649e2f6307f83af2f3bbaa2191b5b has been pushed to the review server.
It is available at http://review.typo3.org/5076
- Status changed from Under Review to Resolved
- % Done changed from 30 to 100
Also available in: Atom
PDF