|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace Nexus\Dumper; |
|
5
|
|
|
|
|
6
|
|
|
use Nexus\Dumper\Communication\Command\DumpLocalCommand; |
|
7
|
|
|
use Nexus\Dumper\Communication\Command\DumpSshCommand; |
|
8
|
|
|
use Nexus\Dumper\Communication\Command\RestoreLocalCommand; |
|
9
|
|
|
use Nexus\Dumper\Communication\Command\RestoreSshCommand; |
|
10
|
|
|
use Xervice\Core\Business\Model\Dependency\DependencyContainerInterface; |
|
11
|
|
|
use Xervice\Core\Business\Model\Dependency\Provider\AbstractDependencyProvider; |
|
12
|
|
|
|
|
13
|
|
|
class DumperDependencyProvider extends AbstractDependencyProvider |
|
14
|
|
|
{ |
|
15
|
|
|
public const DOCKER_FACADE = 'docker.facade'; |
|
16
|
|
|
public const SHELL_FACADE = 'shell.facade'; |
|
17
|
|
|
public const COMMAND_LIST = 'command.list'; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container |
|
21
|
|
|
* |
|
22
|
|
|
* @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface |
|
23
|
|
|
*/ |
|
24
|
|
|
public function handleDependencies(DependencyContainerInterface $container): DependencyContainerInterface |
|
25
|
|
|
{ |
|
26
|
|
|
$container = $this->addShellFacade($container); |
|
27
|
|
|
$container = $this->addDockerFacade($container); |
|
28
|
|
|
$container = $this->addCommandList($container); |
|
29
|
|
|
|
|
30
|
|
|
return $container; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @return array |
|
35
|
|
|
*/ |
|
36
|
|
|
protected function getCommandList(): array |
|
37
|
|
|
{ |
|
38
|
|
|
return [ |
|
39
|
|
|
new DumpLocalCommand(), |
|
40
|
|
|
new DumpSshCommand(), |
|
41
|
|
|
new RestoreLocalCommand(), |
|
42
|
|
|
new RestoreSshCommand() |
|
43
|
|
|
]; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container |
|
48
|
|
|
* |
|
49
|
|
|
* @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface |
|
50
|
|
|
*/ |
|
51
|
|
|
private function addShellFacade(DependencyContainerInterface $container): DependencyContainerInterface |
|
52
|
|
|
{ |
|
53
|
|
|
$container[self::SHELL_FACADE] = function(DependencyContainerInterface $container) { |
|
54
|
|
|
return $container->getLocator()->shell()->facade(); |
|
|
|
|
|
|
55
|
|
|
}; |
|
56
|
|
|
|
|
57
|
|
|
return $container; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container |
|
62
|
|
|
* |
|
63
|
|
|
* @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface |
|
64
|
|
|
*/ |
|
65
|
|
|
private function addDockerFacade(DependencyContainerInterface $container): DependencyContainerInterface |
|
66
|
|
|
{ |
|
67
|
|
|
$container[self::DOCKER_FACADE] = function(DependencyContainerInterface $container) { |
|
68
|
|
|
return $container->getLocator()->dockerClient()->facade(); |
|
69
|
|
|
}; |
|
70
|
|
|
|
|
71
|
|
|
return $container; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container |
|
76
|
|
|
* |
|
77
|
|
|
* @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface |
|
78
|
|
|
*/ |
|
79
|
|
|
protected function addCommandList( |
|
80
|
|
|
DependencyContainerInterface $container |
|
81
|
|
|
): DependencyContainerInterface { |
|
82
|
|
|
$container[self::COMMAND_LIST] = function (DependencyContainerInterface $container) { |
|
|
|
|
|
|
83
|
|
|
return $this->getCommandList(); |
|
84
|
|
|
}; |
|
85
|
|
|
return $container; |
|
86
|
|
|
} |
|
87
|
|
|
} |