|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace Xervice\Web; |
|
5
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
use Xervice\Core\Business\Model\Dependency\DependencyContainerInterface; |
|
8
|
|
|
use Xervice\Core\Business\Model\Dependency\Provider\AbstractDependencyProvider; |
|
9
|
|
|
use Xervice\Web\Business\Dependency\Plugin\PluginCollection; |
|
10
|
|
|
|
|
11
|
|
|
class WebDependencyProvider extends AbstractDependencyProvider |
|
12
|
|
|
{ |
|
13
|
|
|
public const ROUTE_PROVIDER_COLLECTION = 'route.provider.collection'; |
|
14
|
|
|
|
|
15
|
|
|
public const ROUTING_FACADE = 'routing.facade'; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @param DependencyContainerInterface $container |
|
19
|
|
|
* |
|
20
|
|
|
* @return DependencyContainerInterface |
|
21
|
|
|
*/ |
|
22
|
1 |
|
public function handleDependencies(DependencyContainerInterface $container): DependencyContainerInterface |
|
23
|
|
|
{ |
|
24
|
1 |
|
$container = $this->addPluginCollection($container); |
|
25
|
1 |
|
$container = $this->addRoutingFacade($container); |
|
26
|
|
|
|
|
27
|
1 |
|
return $container; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @return \Xervice\Web\Business\Dependency\Plugin\WebProviderPluginInterface[] |
|
32
|
|
|
*/ |
|
33
|
|
|
protected function getRouteProvider(): array |
|
34
|
|
|
{ |
|
35
|
|
|
return []; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container |
|
40
|
|
|
* |
|
41
|
|
|
* @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface |
|
42
|
|
|
*/ |
|
43
|
1 |
|
protected function addPluginCollection( |
|
44
|
|
|
DependencyContainerInterface $container |
|
45
|
|
|
): DependencyContainerInterface { |
|
46
|
|
|
$container[self::ROUTE_PROVIDER_COLLECTION] = function () { |
|
47
|
|
|
return new PluginCollection( |
|
48
|
|
|
$this->getRouteProvider() |
|
49
|
|
|
); |
|
50
|
|
|
}; |
|
51
|
1 |
|
return $container; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container |
|
56
|
|
|
* |
|
57
|
|
|
* @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface |
|
58
|
|
|
*/ |
|
59
|
1 |
|
protected function addRoutingFacade( |
|
60
|
|
|
DependencyContainerInterface $container |
|
61
|
|
|
): DependencyContainerInterface { |
|
62
|
|
|
$container[self::ROUTING_FACADE] = function (DependencyContainerInterface $container) { |
|
63
|
1 |
|
return $container->getLocator()->routing()->facade(); |
|
|
|
|
|
|
64
|
|
|
}; |
|
65
|
1 |
|
return $container; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|