bug #31925 [Form] fix usage of legacy TranslatorInterface (nicolas-grekas)
This PR was merged into the 4.2 branch.
Discussion
----------
[Form] fix usage of legacy TranslatorInterface
| Q | A
| ------------- | ---
| Branch? | 4.2
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Commits
-------
0fbfefe869
[Form] fix usage of legacy TranslatorInterface
This commit is contained in:
commit
0364135989
@ -20,7 +20,8 @@ use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\OptionsResolver\Options;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Symfony\Component\Translation\TranslatorInterface as LegacyTranslatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class FileType extends AbstractType
|
||||
{
|
||||
@ -35,8 +36,14 @@ class FileType extends AbstractType
|
||||
|
||||
private $translator;
|
||||
|
||||
public function __construct(TranslatorInterface $translator = null)
|
||||
/**
|
||||
* @param TranslatorInterface|null $translator
|
||||
*/
|
||||
public function __construct($translator = null)
|
||||
{
|
||||
if (null !== $translator && !$translator instanceof LegacyTranslatorInterface && !$translator instanceof TranslatorInterface) {
|
||||
throw new \TypeError(sprintf('Argument 1 passed to %s() must be an instance of %s, %s given.', __METHOD__, TranslatorInterface::class, \is_object($translator) ? \get_class($translator) : \gettype($translator)));
|
||||
}
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ use Symfony\Component\Form\NativeRequestHandler;
|
||||
use Symfony\Component\Form\RequestHandlerInterface;
|
||||
use Symfony\Component\HttpFoundation\File\File;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class FileTypeTest extends BaseTypeTest
|
||||
{
|
||||
|
Reference in New Issue
Block a user