|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Dock\Installer\System\Mac; |
|
4
|
|
|
|
|
5
|
|
|
use Dock\Docker\Machine\DockerMachineCli; |
|
6
|
|
|
use Dock\Installer\InstallerTask; |
|
7
|
|
|
use Dock\IO\UserInteraction; |
|
8
|
|
|
use Dock\System\Environ\EnvironManipulatorFactory; |
|
9
|
|
|
use SRIO\ChainOfResponsibility\DependentChainProcessInterface; |
|
10
|
|
|
|
|
11
|
|
|
class EnvironmentVariables extends InstallerTask implements DependentChainProcessInterface |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @var UserInteraction |
|
15
|
|
|
*/ |
|
16
|
|
|
private $userInteraction; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var EnvironManipulatorFactory |
|
20
|
|
|
*/ |
|
21
|
|
|
private $environManipulatorFactory; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var DockerMachineCli |
|
25
|
|
|
*/ |
|
26
|
|
|
private $dockerMachineCli; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @param UserInteraction $userInteraction |
|
30
|
|
|
* @param EnvironManipulatorFactory $environManipulatorFactory |
|
31
|
|
|
* @param DockerMachineCli $dockerMachineCli |
|
32
|
|
|
*/ |
|
33
|
|
|
public function __construct(UserInteraction $userInteraction, EnvironManipulatorFactory $environManipulatorFactory, DockerMachineCli $dockerMachineCli) |
|
34
|
|
|
{ |
|
35
|
|
|
$this->userInteraction = $userInteraction; |
|
36
|
|
|
$this->dockerMachineCli = $dockerMachineCli; |
|
37
|
|
|
$this->environManipulatorFactory = $environManipulatorFactory; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* {@inheritdoc} |
|
42
|
|
|
*/ |
|
43
|
|
|
public function run() |
|
44
|
|
|
{ |
|
45
|
|
|
$this->userInteraction->writeTitle('Setting up machine environment variables'); |
|
46
|
|
|
$this->saveEnvironmentVariables(); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* {@inheritdoc} |
|
51
|
|
|
*/ |
|
52
|
|
|
public function dependsOn() |
|
53
|
|
|
{ |
|
54
|
|
|
return ['machine']; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* {@inheritdoc} |
|
59
|
|
|
*/ |
|
60
|
|
|
public function getName() |
|
61
|
|
|
{ |
|
62
|
|
|
return 'shell-env'; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Save the environment variables. |
|
67
|
|
|
*/ |
|
68
|
|
|
protected function saveEnvironmentVariables() |
|
69
|
|
|
{ |
|
70
|
|
|
$environManipulator = $this->environManipulatorFactory->getSystemManipulator(); |
|
71
|
|
|
$environmentDeclaration = $this->dockerMachineCli->getEnvironmentDeclaration(); |
|
72
|
|
|
|
|
73
|
|
|
if (!$environManipulator->has($environmentDeclaration)) { |
|
74
|
|
|
$environManipulator->save($environmentDeclaration); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|