wp-user-avatar
/
third-party
/
vendor
/
symfony
/
translation
/
Exception
/
UnsupportedSchemeException.php
ExceptionInterface.php
2 months ago
IncompleteDsnException.php
2 months ago
InvalidArgumentException.php
2 months ago
InvalidResourceException.php
2 months ago
LogicException.php
2 months ago
MissingRequiredOptionException.php
2 months ago
NotFoundResourceException.php
2 months ago
ProviderException.php
2 months ago
ProviderExceptionInterface.php
2 months ago
RuntimeException.php
2 months ago
UnsupportedSchemeException.php
2 months ago
UnsupportedSchemeException.php
36 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 ProfilePressVendor\Symfony\Component\Translation\Exception; |
| 12 | |
| 13 | use ProfilePressVendor\Symfony\Component\Translation\Bridge; |
| 14 | use ProfilePressVendor\Symfony\Component\Translation\Provider\Dsn; |
| 15 | class UnsupportedSchemeException extends LogicException |
| 16 | { |
| 17 | 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']]; |
| 18 | public function __construct(Dsn $dsn, ?string $name = null, array $supported = []) |
| 19 | { |
| 20 | $provider = $dsn->getScheme(); |
| 21 | if (\false !== $pos = strpos($provider, '+')) { |
| 22 | $provider = substr($provider, 0, $pos); |
| 23 | } |
| 24 | $package = self::SCHEME_TO_PACKAGE_MAP[$provider] ?? null; |
| 25 | if ($package && !class_exists($package['class'])) { |
| 26 | parent::__construct(sprintf('Unable to synchronize translations via "%s" as the provider is not installed; try running "composer require %s".', $provider, $package['package'])); |
| 27 | return; |
| 28 | } |
| 29 | $message = sprintf('The "%s" scheme is not supported', $dsn->getScheme()); |
| 30 | if ($name && $supported) { |
| 31 | $message .= sprintf('; supported schemes for translation provider "%s" are: "%s"', $name, implode('", "', $supported)); |
| 32 | } |
| 33 | parent::__construct($message . '.'); |
| 34 | } |
| 35 | } |
| 36 |