ExceptionInterface.php
2 years ago
IncompleteDsnException.php
1 month ago
InvalidArgumentException.php
2 years ago
InvalidResourceException.php
2 years ago
LogicException.php
2 years ago
MissingRequiredOptionException.php
1 month ago
NotFoundResourceException.php
2 years ago
ProviderException.php
1 month ago
ProviderExceptionInterface.php
2 years ago
RuntimeException.php
2 years ago
UnsupportedSchemeException.php
1 month ago
UnsupportedSchemeException.php
37 lines
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This file is part of the Symfony package. |
| 5 | * |
| 6 | * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | */ |
| 11 | namespace IAWPSCOPED\Symfony\Component\Translation\Exception; |
| 12 | |
| 13 | use IAWPSCOPED\Symfony\Component\Translation\Bridge; |
| 14 | use IAWPSCOPED\Symfony\Component\Translation\Provider\Dsn; |
| 15 | /** @internal */ |
| 16 | class UnsupportedSchemeException extends LogicException |
| 17 | { |
| 18 | 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']]; |
| 19 | public function __construct(Dsn $dsn, string $name = null, array $supported = []) |
| 20 | { |
| 21 | $provider = $dsn->getScheme(); |
| 22 | if (\false !== ($pos = \strpos($provider, '+'))) { |
| 23 | $provider = \substr($provider, 0, $pos); |
| 24 | } |
| 25 | $package = self::SCHEME_TO_PACKAGE_MAP[$provider] ?? null; |
| 26 | if ($package && !\class_exists($package['class'])) { |
| 27 | parent::__construct(\sprintf('Unable to synchronize translations via "%s" as the provider is not installed; try running "composer require %s".', $provider, $package['package'])); |
| 28 | return; |
| 29 | } |
| 30 | $message = \sprintf('The "%s" scheme is not supported', $dsn->getScheme()); |
| 31 | if ($name && $supported) { |
| 32 | $message .= \sprintf('; supported schemes for translation provider "%s" are: "%s"', $name, \implode('", "', $supported)); |
| 33 | } |
| 34 | parent::__construct($message . '.'); |
| 35 | } |
| 36 | } |
| 37 |