init
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user