1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Support\DockerSync; |
4
|
|
|
|
5
|
|
|
use App\Events\BuiltDockerCompose; |
6
|
|
|
use App\Events\StartingPorter; |
7
|
|
|
use App\Events\StartingPorterService; |
8
|
|
|
use App\Events\StoppingPorter; |
9
|
|
|
use App\Events\StoppingPorterService; |
10
|
|
|
use App\Support\Console\ConsoleWriter; |
11
|
|
|
|
12
|
|
|
class EventSubscriber |
13
|
|
|
{ |
14
|
|
|
/** @var DockerSync */ |
15
|
|
|
protected $dockerSync; |
16
|
|
|
|
17
|
191 |
|
public function __construct(DockerSync $dockerSync) |
18
|
|
|
{ |
19
|
191 |
|
$this->dockerSync = $dockerSync; |
20
|
191 |
|
} |
21
|
|
|
|
22
|
1 |
|
public function startAll(StartingPorter $event) |
|
|
|
|
23
|
|
|
{ |
24
|
1 |
|
$this->dockerSync->startDaemon(); |
25
|
1 |
|
} |
26
|
|
|
|
27
|
3 |
|
public function startForService(StartingPorterService $event) |
|
|
|
|
28
|
|
|
{ |
29
|
3 |
|
$this->dockerSync->startDaemon(); |
30
|
3 |
|
} |
31
|
|
|
|
32
|
1 |
|
public function stopAll(StoppingPorter $event) |
|
|
|
|
33
|
|
|
{ |
34
|
1 |
|
$this->dockerSync->stopDaemon(); |
35
|
1 |
|
} |
36
|
|
|
|
37
|
3 |
|
public function stopForService(StoppingPorterService $event) |
|
|
|
|
38
|
|
|
{ |
39
|
3 |
|
$this->dockerSync->stopDaemon(); |
40
|
3 |
|
} |
41
|
|
|
|
42
|
7 |
|
public function adaptDockerCompose(BuiltDockerCompose $event) |
43
|
|
|
{ |
44
|
7 |
|
if ($this->dockerSync->isActive()) { |
45
|
|
|
app(ConsoleWriter::class)->info('Adapting DockerCompose YAML for DockerSync'); |
46
|
|
|
$this->dockerSync->adjustDockerComposeSetup($event->filePath); |
47
|
|
|
} |
48
|
7 |
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Register the listeners for the subscriber. |
52
|
|
|
* |
53
|
|
|
* @param \Illuminate\Events\Dispatcher $events |
54
|
|
|
* |
55
|
|
|
* @return void |
56
|
|
|
*/ |
57
|
191 |
|
public function subscribe($events) |
58
|
|
|
{ |
59
|
191 |
|
$events->listen(StartingPorter::class, static::class.'@startAll'); |
60
|
191 |
|
$events->listen(StartingPorterService::class, static::class.'@startForService'); |
61
|
191 |
|
$events->listen(StoppingPorter::class, static::class.'@stopAll'); |
62
|
191 |
|
$events->listen(StoppingPorterService::class, static::class.'@stopForService'); |
63
|
191 |
|
$events->listen(BuiltDockerCompose::class, static::class.'@adaptDockerCompose'); |
64
|
191 |
|
} |
65
|
|
|
} |
66
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.