Issues (56)

DependencyInjection/Compiler/LocaleScopePass.php (3 issues)

Labels
Severity
1
<?php
2
/**
3
 * @author    oliverde8<[email protected]>
4
 * @category  @category  oliverde8/ComfyBundle
5
 */
6
7
namespace oliverde8\ComfyBundle\DependencyInjection\Compiler;
8
9
10
use oliverde8\ComfyBundle\Resolver\ScopeResolverInterface;
11
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
12
use Symfony\Component\DependencyInjection\ContainerBuilder;
13
use Symfony\Component\Intl\Exception\MissingResourceException;
0 ignored issues
show
The type Symfony\Component\Intl\E...issingResourceException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Symfony\Component\Intl\Intl;
0 ignored issues
show
The type Symfony\Component\Intl\Intl was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Symfony\Component\Intl\Locales;
0 ignored issues
show
The type Symfony\Component\Intl\Locales was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
17
class LocaleScopePass implements CompilerPassInterface
18
{
19
20
    /**
21
     * You can modify the container here before it is dumped to PHP code.
22
     */
23
    public function process(ContainerBuilder $container)
24
    {
25
        // TODO Need to check if this is indeed the locale provider to use.
26
        $scopes = [
27
            "default" => "Default scope label",
28
        ];
29
30
        foreach (Locales::getLocales() as $code) {
31
            $leveledCode = str_replace("_", "/", $code);
32
            try {
33
                $name = Locales::getName($code);
34
            } catch (MissingResourceException $e) {
35
                $name = $code;
36
            }
37
38
            $scopes["default/$leveledCode"] = $name;
39
        }
40
41
        $definition = $container->getDefinition('oliverde8.comfy_bundle.scope_resolver.locales');
42
        $definition->setArgument('$scopes', $scopes);
43
        $definition->setArgument('$defaultScope', "default");
44
    }
45
}