1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Sylius package. |
5
|
|
|
* |
6
|
|
|
* (c) Paweł Jędrzejewski |
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 Sylius\Bundle\SettingsBundle\Resolver; |
13
|
|
|
|
14
|
|
|
use Sylius\Component\Registry\NonExistingServiceException; |
15
|
|
|
use Sylius\Component\Registry\ServiceRegistry; |
16
|
|
|
use Sylius\Component\Registry\ServiceRegistryInterface; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @author Steffen Brem <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
final class ResolverServiceRegistry implements ServiceRegistryInterface |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var ServiceRegistryInterface |
25
|
|
|
*/ |
26
|
|
|
private $decoratedRegistry; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var SettingsResolverInterface |
30
|
|
|
*/ |
31
|
|
|
private $defaultResolver; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param ServiceRegistryInterface $decoratedRegistry |
35
|
|
|
* @param SettingsResolverInterface $defaultResolver |
36
|
|
|
*/ |
37
|
|
|
public function __construct(ServiceRegistryInterface $decoratedRegistry, SettingsResolverInterface $defaultResolver) |
38
|
|
|
{ |
39
|
|
|
$this->decoratedRegistry = $decoratedRegistry; |
40
|
|
|
$this->defaultResolver = $defaultResolver; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* {@inheritdoc} |
45
|
|
|
*/ |
46
|
|
|
public function all() |
47
|
|
|
{ |
48
|
|
|
return $this->decoratedRegistry->all(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* {@inheritdoc} |
53
|
|
|
*/ |
54
|
|
|
public function register($type, $service) |
55
|
|
|
{ |
56
|
|
|
$this->decoratedRegistry->register($type, $service); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* {@inheritdoc} |
61
|
|
|
*/ |
62
|
|
|
public function unregister($type) |
63
|
|
|
{ |
64
|
|
|
$this->decoratedRegistry->unregister($type); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* {@inheritdoc} |
69
|
|
|
*/ |
70
|
|
|
public function has($type) |
71
|
|
|
{ |
72
|
|
|
return $this->decoratedRegistry->has($type); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* {@inheritdoc} |
77
|
|
|
*/ |
78
|
|
|
public function get($type) |
79
|
|
|
{ |
80
|
|
|
if (!$this->decoratedRegistry->has($type)) { |
81
|
|
|
return $this->defaultResolver; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
return $this->decoratedRegistry->get($type); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|