-
Notifications
You must be signed in to change notification settings - Fork 0
/
TackerServiceProvider.php
41 lines (34 loc) · 1.3 KB
/
TackerServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace Brick\Provider;
use Pimple\Container;
use Tacker\Configurator;
use Tacker\LoaderBuilder;
use Tacker\Normalizer\PimpleNormalizer;
class TackerServiceProvider implements \Pimple\ServiceProviderInterface
{
public function register(Container $pimple)
{
$pimple['tacker.config'] = function ($pimple) {
$options = isset($pimple['tacker.options']) ? $pimple['tacker.options'] : [];
$paths = isset($pimple['root_dir']) ? [$pimple['root_dir']] : [];
$debug = isset($pimple['debug']) ? $pimple['debug'] : true;
return $options + [
'cache_dir' => null,
'debug' => $debug,
'paths' => $paths,
];
};
$pimple['tacker.builder'] = function ($pimple) {
$config = $pimple['tacker.config'];
return LoaderBuilder::create($config['paths'], $config['cache_dir'], $config['debug'])
->addDefaultNormalizers()
->configureNormalizers(function ($chain) use ($pimple) {
$chain->add(new PimpleNormalizer($pimple));
})
;
};
$pimple['tacker.configurator'] = function ($pimple) {
return new Configurator($pimple['tacker.builder']->build());
};
}
}