8000 [Translator] Deprecated interface still required for Form · Issue #30591 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Translator] Deprecated interface still required for Form #30591

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

Closed
althaus opened this issue Mar 18, 2019 · 4 comments
Closed

[Translator] Deprecated interface still required for Form #30591

althaus opened this issue Mar 18, 2019 · 4 comments

Comments

@althaus
Copy link
Contributor
althaus commented Mar 18, 2019

Symfony version(s) affected: 4.2.x

Description
According to the current docs the Symfony\Component\Translation\TranslatorInterface has been superseded by the Symfony\Contracts\Translation\TranslatorInterface. I've updated our custom GettextTranslator and dropped the deprecated interface.

This leads to an exception in the form handling:

Argument 1 passed to Symfony\Component\Form\Extension\Core\Type\TransformationFailureExtension::__construct() must implement interface Symfony\Component\Translation\TranslatorInterface or be null, instance of Acme\Translation\GettextTranslator given

How to reproduce
See above. Use a custom Translator and only implement the new interface(s).

Possible Solution
I'm not sure how Symfony exactly handles an interface exchange, but it smells like the doc should be improved stating that the old interface is still required in combination with the form/validator? Otherwise the TransformationFailureExtension could be improved to accept both interfaces? Currently the upgrade doc reads like "just replace the interface".

Cheers
Matthias

@althaus althaus changed the title [Translator] Deprecated interface still required? [Translator] Deprecated interface still required for Form? Mar 18, 2019
@nicolas-grekas
Copy link
Member

that's a bug in TransformationFailureExtension, would you mind sending a PR to remove the type-hint (and replace it with a docblock)?

@nicolas-grekas
Copy link
Member
8000

see CsrfValidationListener for an example

@althaus
Copy link
Contributor Author
althaus commented Mar 18, 2019

I'll take a look. It's then broken in the CoreExtension, too. Is it enough to fix this in the classes or does it need some fixing to bind the proper service without the type hint?

@althaus althaus changed the title [Translator] Deprecated interface still required for Form? [Translator] Deprecated interface still required for Form Mar 18, 2019
@nicolas-grekas
Copy link
Member

We don't use autowiring/bindings in core so nothing to do there.

althaus added a commit to althaus/symfony that referenced this issue Mar 18, 2019
…#30591) (althaus)

This PR was merged into the 4.2 branch.

Discussion
----------

Fixed usage of TranslatorInterface in form extension (fixes #30591)

| Q             | A
| ------------- | ---
| Branch?       | 4.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #30591
| License       | MIT

This PR replaces the fixed usage of the deprecated TranslatorInterface in the form extension with a soft one accepting either the old or the new interface.

Commits
-------

d8092c7 Fixed usage of TranslatorInterface in form extension (fixes #30591)
fabpot added a commit that referenced this issue Mar 22, 2019
* 4.2:
  [Phpunit] fixed support for PHP 5.3
  Response prepare method update
  [Workflow] Added missing license header
  Fix case when multiple loaders are providing paths for the same namespace
  Check if Client exists when test.client does not exist, to provide clearer exception message
  throw TypeErrors to prepare for type hints in 5.0
  [Form] Preventing validation of children if parent with Valid constraint has no validation groups
  [Form] Added ResetInterface to CachingFactoryDecorator
  Remove deprecated usage
  [Tests] fixed compatbility of assertEquals(): void
  Fixed usage of TranslatorInterface in form extension (fixes #30591)
  [Intl][4.2] Fix test
  [Intl] Fix test
  [Validator] Add the missing translations for the Arabic (ar) locale
  [Intl] Add compile binary
  Fix DebugCommand when chain loader is involved
  [Form] Fixed some phpdocs
eborges78 pushed a commit to eborges78/symfony that referenced this issue Mar 27, 2019
@fabpot fabpot mentioned this issue Apr 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants
0