-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathProgram.php
42 lines (36 loc) · 1.18 KB
/
Program.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php declare(strict_types=1);
namespace ApiClients\Client\Supervisord\Resource\Async;
use ApiClients\Client\Supervisord\CommandBus\Command\Program\StartCommand;
use ApiClients\Client\Supervisord\CommandBus\Command\Program\StopCommand;
use ApiClients\Client\Supervisord\CommandBus\Command\ProgramCommand;
use ApiClients\Client\Supervisord\Resource\Program as BaseProgram;
use React\Promise\PromiseInterface;
class Program extends BaseProgram
{
public function refresh(): PromiseInterface
{
return $this->handleCommand(new ProgramCommand($this->name));
}
/**
* Reason behind the enable/disable names is that start is in
* use by an property.
*
* @return PromiseInterface
*/
public function enable(): PromiseInterface
{
return $this->handleCommand(new StartCommand($this->name));
}
public function disable(): PromiseInterface
{
return $this->handleCommand(new StopCommand($this->name));
}
public function restart(): PromiseInterface
{
return $this->disable()->then(function () {
return $this->enable();
})->then(function () {
return $this->refresh();
});
}
}