drop MessageSelector support in the Translator

This commit is contained in:
Christian Flothmann 2017-09-12 18:35:33 +02:00
parent 96bec9de77
commit 2028a83689
3 changed files with 4 additions and 6 deletions

View File

@ -63,7 +63,7 @@ class Translator extends BaseTranslator implements WarmableInterface
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function __construct(ContainerInterface $container, $formatter, string $defaultLocale, array $loaderIds = array(), array $options = array()) public function __construct(ContainerInterface $container, MessageFormatterInterface $formatter, string $defaultLocale, array $loaderIds = array(), array $options = array())
{ {
$this->container = $container; $this->container = $container;
$this->loaderIds = $loaderIds; $this->loaderIds = $loaderIds;

View File

@ -6,6 +6,7 @@ CHANGELOG
* removed the backup feature of the `FileDumper` class * removed the backup feature of the `FileDumper` class
* removed `TranslationWriter::writeTranslations()` method * removed `TranslationWriter::writeTranslations()` method
* removed support for passing `MessageSelector` instances to the constructor of the `Translator` class
3.4.0 3.4.0
----- -----

View File

@ -85,14 +85,11 @@ class Translator implements TranslatorInterface, TranslatorBagInterface
* *
* @throws InvalidArgumentException If a locale contains invalid characters * @throws InvalidArgumentException If a locale contains invalid characters
*/ */
public function __construct($locale, $formatter = null, $cacheDir = null, $debug = false) public function __construct($locale, MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = false)
{ {
$this->setLocale($locale); $this->setLocale($locale);
if ($formatter instanceof MessageSelector) { if (null === $formatter) {
$formatter = new MessageFormatter($formatter);
@trigger_error(sprintf('Passing a "%s" instance into the "%s" as a second argument is deprecated since version 3.4 and will be removed in 4.0. Inject a "%s" implementation instead.', MessageSelector::class, __METHOD__, MessageFormatterInterface::class), E_USER_DEPRECATED);
} elseif (null === $formatter) {
$formatter = new MessageFormatter(); $formatter = new MessageFormatter();
} }