ExceptionInterface.php
4 years ago
IncompleteDsnException.php
1 year ago
InvalidArgumentException.php
4 years ago
InvalidResourceException.php
4 years ago
LogicException.php
4 years ago
MissingRequiredOptionException.php
1 year ago
NotFoundResourceException.php
4 years ago
ProviderException.php
1 year ago
ProviderExceptionInterface.php
1 year ago
RuntimeException.php
4 years ago
UnsupportedSchemeException.php
1 year ago
index.php
3 years ago
UnsupportedSchemeException.php
27 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\Translation\Exception; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Symfony\Component\Translation\Bridge; |
| 5 | use MailPoetVendor\Symfony\Component\Translation\Provider\Dsn; |
| 6 | class UnsupportedSchemeException extends LogicException |
| 7 | { |
| 8 | private const SCHEME_TO_PACKAGE_MAP = ['crowdin' => ['class' => Bridge\Crowdin\CrowdinProviderFactory::class, 'package' => 'symfony/crowdin-translation-provider'], 'loco' => ['class' => Bridge\Loco\LocoProviderFactory::class, 'package' => 'symfony/loco-translation-provider'], 'lokalise' => ['class' => Bridge\Lokalise\LokaliseProviderFactory::class, 'package' => 'symfony/lokalise-translation-provider']]; |
| 9 | public function __construct(Dsn $dsn, ?string $name = null, array $supported = []) |
| 10 | { |
| 11 | $provider = $dsn->getScheme(); |
| 12 | if (\false !== ($pos = \strpos($provider, '+'))) { |
| 13 | $provider = \substr($provider, 0, $pos); |
| 14 | } |
| 15 | $package = self::SCHEME_TO_PACKAGE_MAP[$provider] ?? null; |
| 16 | if ($package && !\class_exists($package['class'])) { |
| 17 | parent::__construct(\sprintf('Unable to synchronize translations via "%s" as the provider is not installed; try running "composer require %s".', $provider, $package['package'])); |
| 18 | return; |
| 19 | } |
| 20 | $message = \sprintf('The "%s" scheme is not supported', $dsn->getScheme()); |
| 21 | if ($name && $supported) { |
| 22 | $message .= \sprintf('; supported schemes for translation provider "%s" are: "%s"', $name, \implode('", "', $supported)); |
| 23 | } |
| 24 | parent::__construct($message . '.'); |
| 25 | } |
| 26 | } |
| 27 |