-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Make Templating optional #520
Conversation
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.
Currently this PR is made of multiple BC-break.
I think you'll have to duplicate the BaseHelper so far (one in the Helper folder and one in the Helper/Templating).
Also you'll have to keep the old alias/service declaration. But you can add some TODO for the next major in order to remove the deprecated code.
the problem isn't a possible duplicated base helper, but if we really need duplicated DateTimeHelper code (if i can't have the Templating ones extend the Twig ones) the question is more if it is really a BC break if the or is it an BC break if |
If someone is doing |
so the only way without BC break would be to duplicate all the helper classes, because i probably can't change the constructor to give them the Twig Helper. right? |
I'm not sure about the purpose of this PR and the strategy you have in mind to do it so I currently cannot say what is the best way to do this without BC-break. A constructor can be change if you do it this way:
to
or
but it has to still work if you pass the old elements. |
the main reason was to make the templating dependency optional for this i moved/created helpers that doesn't extend on templating Helper (no BC) because of duplicated code, i wanted the templating helper use the twig helper, but i can't do that because it would change the templating Helper in a way that would be a BC.
|
You can have a
This is BC. |
This wouldn't work with the current php version defined in because my projects aren't for 8.0 yet i would like to avoid that. |
You dont have to use the typehint, just the phpdoc. Changing
to
|
Could you please rebase your PR and fix merge conflicts? |
Could you please rebase your PR and fix merge conflicts? |
Hello. I'm currently working on a codebase that uses this package and this PR would allow us to remove the templating component from our dependencies. I see that progress on the PR is stalling somehow. Is there anything I can do to help? |
@VincentLanglet should i mark the Templating Helpers as Deprecated to be removed in a later PR? |
Yes please :) And I assume you can add a NEXT_MAJOR: Remove this code above
then. |
I made some reviews. I think the PR seems ready, it just require some deprecation message I think @Hanmac will add. |
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.
Same for others and it will be perfect
And take a look to the linter ;) |
src/Helper/NumberHelper.php
Outdated
* @param array $symbols The symbols used by \NumberFormatter | ||
* @param string|null $locale The locale used to format the number | ||
*/ | ||
public function format($number, int $style, array $attributes = [], array $textAttributes = [], array $symbols = [], ?string $locale = null): string |
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.
do we need to make all format methods public? or the class should be used with the other methods? is this used outside this 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.
Looking at the interface methods, I wonder if it shouldn't be better to rename the class/interface to
DateTimeFormatter
NumberFormatter
LocaleSomething
It could be better than Helper
(and tests are failing) |
i don't know about different helper names, can you decide before i change the code again? |
To me, DateTimeFormatter and NumberFormatter are much better names since all the methods are "formatFoo". Looking at https://github.com/sonata-project/SonataIntlBundle/blob/2.x/src/Twig/LocaleRuntime.php, all three method are returning a localized name. I don't know if something like a Let's wait for @jordisala1991 opinion. |
Agree! To me if we are introducing new code, let's try to be as good as possible, because we are going to maintain it. |
@jordisala1991 your opinion for better names? |
I talked with him. DateTimeFormatter are ok. |
i did better names, also i made twig use the interfaces instead. and i added the interfaces to autowire |
Some static analysis build are failing |
]) | ||
|
||
->set('sonata.intl.templating.helper.datetime', '%sonata.intl.templating.helper.datetime.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.
Removing a service alias is a BC break (or this kind of change was handled as a BC break a few years ago...)
Subject
This makes the Symfony/Templating Dependency Optional.
The Twig Components don't need it, so they use the new base classes.
The Old Services for the Helper still exist, but they are only loaded when the templating component is used.
i don't know if it is 100% BC or not.
I am targeting this branch, because it should be BC.
Closes #518.
Changelog