-
Notifications
You must be signed in to change notification settings - Fork 11
Conversation
3c7d0fe
to
baced10
Compare
|
||
$tokens['{' . $name . '}'] = $tokenProvider->provideValue($uriContext, $optionsResolver->resolve($options['options'])); | ||
if ($isEmpty && true === $tokenProviderOptions['collapse_empty']) { | ||
$tokens[$tokenString . '/'] = (string) $tokenValue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We treat /
as a de facto empty value and apply the same logic as we would for an empty string.
👍 |
private function configureGlobalOptions(OptionsResolver $optionsResolver) | ||
{ | ||
$optionsResolver->setDefaults(array( | ||
'collapse_empty' => false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about allow_empty
? Collapse empty is pretty vague imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, collapse_empty
hints that it does more than allowing empty, and it also allows to add a real allow_empty
in the future if required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, imo:
- If a token is empty, it's trailing slash is stripped
- By default, a token cannot be empty. An empty token throws an exception
- You can change this behaviour by overriding
allow_empty
, which will allow an empty token
I think they are 2 generic and seperate processes. One is to always remove trailing slashes when a token is empty. The other is to allow or not to allow empty tokens. Only the second process can be changed by this option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I undetstand your last point. But thinking about I can't see a situation where you would want to allow empty and not collapse slashes, so +1 for allow_empty
.
baced10
to
2b635e4
Compare
// if the last segment is empty and allow empty is true, then remove the leading slash | ||
array( | ||
'/{locale}/{parent}', | ||
'/de', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new.. if the the last segment is empty and allow empty is true, then remove the leading slash
Added some more logic and changed name from |
👍 |
Merged, see doc PR: symfony-cmf/symfony-cmf-docs#668 |
This PR:
collapse_empty
which permits empty tokens and removes any trailing slash.Fixes: #35