Skip to content

[ThemeBundle] Remove deprecated translator selector usage#9277

Closed
adrienlucas wants to merge 1 commit intoSylius:1.1from
adrienlucas:remove-deprecated-translator-selector-usage
Closed

[ThemeBundle] Remove deprecated translator selector usage#9277
adrienlucas wants to merge 1 commit intoSylius:1.1from
adrienlucas:remove-deprecated-translator-selector-usage

Conversation

@adrienlucas
Copy link
Copy Markdown
Contributor

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Related tickets NA
License MIT

Passing a "Symfony\Component\Translation\MessageSelector" instance into the "Symfony\Component\Translation\Translator::__construct" as a second argument is deprecated since Symfony 3.4 and will be removed in 4.0. Inject a "Symfony\Component\Translation\Formatter\MessageFormatterInterface" implementation instead.

See https://github.com/symfony/symfony/blob/b9a2e21326ad93aab1350e566afced701942ac6d/src/Symfony/Component/Translation/Translator.php#L90

@adrienlucas adrienlucas force-pushed the remove-deprecated-translator-selector-usage branch from fe58d19 to 088eda2 Compare March 23, 2018 16:19
$messageFormatter = new class implements MessageFormatterInterface {
public function format($message, $locale, array $parameters = array())
{
return strtr($message, $parameters);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can even be simplified to return $message;

@lchrusciel lchrusciel requested a review from pamil March 26, 2018 06:47
@lchrusciel
Copy link
Copy Markdown
Contributor

I believe it should be open to 1.0.

@adrienlucas
Copy link
Copy Markdown
Contributor Author

@lchrusciel it seems that the 1.0 version require "symfony/symfony": "^3.3.13" while the deprecation has been added to Symfony 3.4.
The 3.4 version is required as of Sylius 1.1, so maybe I should request the change against this last one ?

@lchrusciel
Copy link
Copy Markdown
Contributor

You are right. It should be opened to 1.1

@adrienlucas adrienlucas force-pushed the remove-deprecated-translator-selector-usage branch from 088eda2 to 13f94dd Compare March 26, 2018 14:18
@adrienlucas adrienlucas changed the base branch from master to 1.1 March 26, 2018 14:21
@adrienlucas
Copy link
Copy Markdown
Contributor Author

adrienlucas commented Mar 26, 2018

@lchrusciel done !

Edit : and also squashed btw !

public function __construct(
TranslatorLoaderProviderInterface $loaderProvider,
TranslatorResourceProviderInterface $resourceProvider,
MessageSelector $messageSelector,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 BC break alert 🚨

The way we can solve it here is to remove the typehint and do instanceof checks inside to accept MessageSelector|MessageFormatterInterface. We'll also need tests which use both of them.

@pamil pamil added Maintenance CI configurations, READMEs, releases, etc. Symfony 4.0 labels Apr 4, 2018
@pamil pamil modified the milestones: 1.1, 1.2 Apr 4, 2018
@pamil
Copy link
Copy Markdown
Contributor

pamil commented Apr 4, 2018

Thanks for the effort to make this PR! In my opinion, it should go to 1.2 (master) as it isn't a bugfix but a deprecation removal (and I'd like to keep bugfix branches changes as small as possible).

@pamil pamil removed this from the 1.2 milestone Apr 27, 2018
@pamil pamil closed this in #9366 Apr 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Maintenance CI configurations, READMEs, releases, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants