Skip to content
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

Reduce use of deprecated Laminas\ServiceManager\ConfigInterface #141

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,6 @@
<ArgumentTypeCoercion>
<code><![CDATA[$this->creationOptions]]></code>
</ArgumentTypeCoercion>
<DeprecatedClass>
<code><![CDATA[new Config($config['translator_plugins'])]]></code>
</DeprecatedClass>
<DeprecatedInterface>
<code><![CDATA[LoaderPluginManagerFactory]]></code>
</DeprecatedInterface>
Expand Down Expand Up @@ -876,19 +873,6 @@
</PossiblyNullReference>
</file>
<file src="test/Translator/TranslatorTest.php">
<DeprecatedClass>
<code><![CDATA[new Config([
'services' => [
'test' => $loader,
],
])]]></code>
<code><![CDATA[new Config([
'services' => [
'test' => $loader,
],
])]]></code>
<code><![CDATA[new Config(['services' => ['test' => $loader]])]]></code>
</DeprecatedClass>
<NullArgument>
<code><![CDATA[null]]></code>
<code><![CDATA[null]]></code>
Expand Down
3 changes: 1 addition & 2 deletions src/Translator/LoaderPluginManagerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Laminas\I18n\Translator;

use Laminas\ServiceManager\Config;
use Laminas\ServiceManager\FactoryInterface;
use Laminas\ServiceManager\ServiceLocatorInterface;
use Laminas\ServiceManager\ServiceManager;
Expand Down Expand Up @@ -55,7 +54,7 @@ public function __invoke(ContainerInterface $container, $name, ?array $options =
}

// Wire service configuration for translator_plugins
(new Config($config['translator_plugins']))->configureServiceManager($pluginManager);
$pluginManager->configure($config['translator_plugins']);

return $pluginManager;
}
Expand Down
14 changes: 5 additions & 9 deletions test/Translator/TranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Laminas\EventManager\EventInterface;
use Laminas\I18n\Translator\TextDomain;
use Laminas\I18n\Translator\Translator;
use Laminas\ServiceManager\Config;
use LaminasTest\I18n\TestCase;
use LaminasTest\I18n\Translator\TestAsset\Loader as TestLoader;
use Locale;
Expand Down Expand Up @@ -157,13 +156,12 @@ public function testTranslate(): void
{
$loader = new TestLoader();
$loader->textDomain = new TextDomain(['foo' => 'bar']);
$config = new Config([
$pm = $this->translator->getPluginManager();
Copy link
Member

Choose a reason for hiding this comment

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

@ramchale
For the future: Please use meaningful names and no abbreviations like these. Also in tests.
Thanks in advance! 👍🏻

$pm->configure([
'services' => [
'test' => $loader,
],
]);
$pm = $this->translator->getPluginManager();
$config->configureServiceManager($pm);
$this->translator->setPluginManager($pm);
$this->translator->addTranslationFile('test', null);

Expand All @@ -190,9 +188,8 @@ public function testTranslationsAreStoredInCache(): void

$loader = new TestLoader();
$loader->textDomain = new TextDomain(['foo' => 'bar']);
$config = new Config(['services' => ['test' => $loader]]);
$plugins = $this->translator->getPluginManager();
$config->configureServiceManager($plugins);
$plugins->configure(['services' => ['test' => $loader]]);
$this->translator->setPluginManager($plugins);
$this->translator->addTranslationFile('test', null);

Expand Down Expand Up @@ -537,13 +534,12 @@ public function testNullMessageArgumentShouldReturnAnEmptyString(): void
{
$loader = new TestLoader();
$loader->textDomain = new TextDomain(['foo' => 'bar']);
$config = new Config([
$pm = $this->translator->getPluginManager();
$pm->configure([
'services' => [
'test' => $loader,
],
]);
$pm = $this->translator->getPluginManager();
$config->configureServiceManager($pm);
$this->translator->setPluginManager($pm);
$this->translator->addTranslationFile('test', null);

Expand Down