-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prefix every filter with sonata_
to avoid conflict
#512
Conversation
It would be nice to prefix our functions, but also IMO we should deprecate the old methods. To do so, maybe it is easier if you introduce twigRuntime for the new functions, so you dont rely on same implementation, and can add a deprecation message. |
1896e53
to
de266f2
Compare
new TwigFilter('format_time', [$this, 'formatTime'], ['is_safe' => ['html']]), // NEXT_MAJOR: Remove this line | ||
new TwigFilter('sonata_format_time', [$this, 'formatTime'], ['is_safe' => ['html']]), | ||
new TwigFilter('format_datetime', [$this, 'formatDatetime'], ['is_safe' => ['html']]), // NEXT_MAJOR: Remove this line | ||
new TwigFilter('sonata_format_datetime', [$this, 'formatDatetime'], ['is_safe' => ['html']]), |
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.
Those should use the new runtime directly
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.
Done
@trigger_error(sprintf( | ||
'The %s method is deprecated since 2.x and will be removed on 3.0. '. | ||
'Use %s::%s instead.', | ||
__METHOD__, | ||
DateTimeRuntime::class, | ||
__METHOD__, | ||
), \E_USER_DEPRECATED); |
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.
IMO these messages should encourage the user to use the new sonata_*
filters instead of runtime class.
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.
Done
To avoid conflict for users installing both |
SonataAdmin is using the format_datetime template of SonataIntl when this bundle is used ; which used the sonata_format_datetime twig method. Also people might want to use sometimes one and sometimes another method. |
Not sure if I understand, but what I meant is that this PR provides alternative |
Currently, if you use both sonata-intl and twig-intl, there is an issue even if you are using none of these methods : If the twig intl is declared after the sonata intl one, the datetime field from sonataAdmin is crashing. If the twig intl is declared after the sonata intl one, with this PR it will be possible for the user to have no issue
If the sonata intl is declared after the twig intl one, indeed there will still be an issue so far. It will be fixed in next major. |
What bundles of Sonata make use of this functions? (Only the non deprecated / abandoned) |
Only deprecated/abandoned one are using them. Can we merge this PR, at least as a first step ? |
if none of the Sonata bundles are using those features. We could even study if this bundle is really needed or we can deprecate it. But that is another topic, IMO you can merge, yes |
None are using directly those methods. But there are templates used by SonataAdmin (which is the issue I try to solve). |
The last release is broken, because |
Can you do the Pr to fix the three runtime ? (Or i'll do later) I m currently on phone ? |
Would. be nice to have a minimal test setup that catches those basic errors |
Found time for #514 |
Subject
I am targeting this branch, because minor.
This might be annoying to have a
sonata_
prefix, but I don't see an other way to be sure to avoid a conflict with eithertwigIntl
or another library.Closes #299.
Changelog