|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ICanBoogie\CLDR\Generator; |
|
4
|
|
|
|
|
5
|
|
|
use ICanBoogie\CLDR\Cache\CacheCollection; |
|
6
|
|
|
use ICanBoogie\CLDR\Cache\FileCache; |
|
7
|
|
|
use ICanBoogie\CLDR\Cache\RuntimeCache; |
|
8
|
|
|
use ICanBoogie\CLDR\Generator\Command\GenerateCalendarPreferenceData; |
|
9
|
|
|
use ICanBoogie\CLDR\Generator\Command\GenerateCurrencyData; |
|
10
|
|
|
use ICanBoogie\CLDR\Generator\Command\GenerateHasContextTransforms; |
|
11
|
|
|
use ICanBoogie\CLDR\Generator\Command\GenerateLocaleData; |
|
12
|
|
|
use ICanBoogie\CLDR\Generator\Command\GenerateSequenceCompanion; |
|
13
|
|
|
use ICanBoogie\CLDR\Generator\Command\GenerateTerritoryData; |
|
14
|
|
|
use ICanBoogie\CLDR\Generator\Command\GenerateUnitsCompanion; |
|
15
|
|
|
use ICanBoogie\CLDR\Provider; |
|
16
|
|
|
use ICanBoogie\CLDR\Repository; |
|
17
|
|
|
use Psr\Container\ContainerInterface; |
|
18
|
|
|
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass; |
|
19
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
20
|
|
|
|
|
21
|
|
|
final class ContainerProvider |
|
22
|
|
|
{ |
|
23
|
|
|
private const COMMANDS = [ |
|
24
|
|
|
GenerateCalendarPreferenceData::class, |
|
25
|
|
|
GenerateCurrencyData::class, |
|
26
|
|
|
GenerateHasContextTransforms::class, |
|
27
|
|
|
GenerateLocaleData::class, |
|
28
|
|
|
GenerateSequenceCompanion::class, |
|
29
|
|
|
GenerateTerritoryData::class, |
|
30
|
|
|
GenerateUnitsCompanion::class, |
|
31
|
|
|
]; |
|
32
|
|
|
|
|
33
|
|
|
public static function provide_container(): ContainerInterface |
|
34
|
|
|
{ |
|
35
|
|
|
$container = new ContainerBuilder(); |
|
36
|
|
|
$container->addCompilerPass(new AddConsoleCommandPass()); |
|
37
|
|
|
|
|
38
|
|
|
$container->register(Repository::class) |
|
39
|
|
|
->setFactory([ self::class, 'repository_factory' ]); |
|
40
|
|
|
|
|
41
|
|
|
foreach (self::COMMANDS as $command) { |
|
42
|
|
|
$container |
|
43
|
|
|
->register($command) |
|
44
|
|
|
->addTag('console.command') |
|
45
|
|
|
->setAutowired(true); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
$container->compile(); |
|
49
|
|
|
|
|
50
|
|
|
return $container; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public static function repository_factory(): Repository |
|
54
|
|
|
{ |
|
55
|
|
|
$provider = new Provider\CachedProvider( |
|
56
|
|
|
new Provider\WebProvider(), |
|
57
|
|
|
new CacheCollection([ |
|
58
|
|
|
new RuntimeCache(), |
|
59
|
|
|
new FileCache(CACHE) |
|
|
|
|
|
|
60
|
|
|
]) |
|
61
|
|
|
); |
|
62
|
|
|
|
|
63
|
|
|
return new Repository($provider); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|