Skip to content

Commit

Permalink
Merge pull request #141 from ramchale/reduce-deprecated-Config
Browse files Browse the repository at this point in the history
Reduce use of deprecated Laminas\ServiceManager\ConfigInterface
  • Loading branch information
gsteel authored Oct 22, 2024
2 parents fbeaa2a + e6d0d4c commit 5ed7e5c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 27 deletions.
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();
$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

0 comments on commit 5ed7e5c

Please sign in to comment.