This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace Esun\MultiLocaleTranslation\Model;
use Esun\MultiLocaleTranslation\Api\TranslationProviderInterface;
use Magento\Framework\Exception\LocalizedException;
class ProviderPool
{
/**
* @param array<string, TranslationProviderInterface> $providers
*/
public function __construct(private readonly array $providers = [])
{
}
public function get(string $code): TranslationProviderInterface
{
$provider = $this->providers[$code] ?? null;
if (!$provider instanceof TranslationProviderInterface) {
throw new LocalizedException(__('Translation provider "%1" is not available.', $code));
}
return $provider;
}
}