Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 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
 
12
namespace Symfony\Component\Translation\Exception;
13
 
14
use Symfony\Component\Translation\Bridge;
15
use Symfony\Component\Translation\Provider\Dsn;
16
 
17
class UnsupportedSchemeException extends LogicException
18
{
19
    private const SCHEME_TO_PACKAGE_MAP = [
20
        'crowdin' => [
21
            'class' => Bridge\Crowdin\CrowdinProviderFactory::class,
22
            'package' => 'symfony/crowdin-translation-provider',
23
        ],
24
        'loco' => [
25
            'class' => Bridge\Loco\LocoProviderFactory::class,
26
            'package' => 'symfony/loco-translation-provider',
27
        ],
28
        'lokalise' => [
29
            'class' => Bridge\Lokalise\LokaliseProviderFactory::class,
30
            'package' => 'symfony/lokalise-translation-provider',
31
        ],
32
    ];
33
 
34
    public function __construct(Dsn $dsn, string $name = null, array $supported = [])
35
    {
36
        $provider = $dsn->getScheme();
37
        if (false !== $pos = strpos($provider, '+')) {
38
            $provider = substr($provider, 0, $pos);
39
        }
40
        $package = self::SCHEME_TO_PACKAGE_MAP[$provider] ?? null;
41
        if ($package && !class_exists($package['class'])) {
42
            parent::__construct(sprintf('Unable to synchronize translations via "%s" as the provider is not installed; try running "composer require %s".', $provider, $package['package']));
43
 
44
            return;
45
        }
46
 
47
        $message = sprintf('The "%s" scheme is not supported', $dsn->getScheme());
48
        if ($name && $supported) {
49
            $message .= sprintf('; supported schemes for translation provider "%s" are: "%s"', $name, implode('", "', $supported));
50
        }
51
 
52
        parent::__construct($message.'.');
53
    }
54
}