|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Abacaphiliac\DoctrineORMDiagnosticsModule; |
|
4
|
|
|
|
|
5
|
|
|
use DoctrineModule\Component\Console\Output\PropertyOutput; |
|
6
|
|
|
use Symfony\Component\Console\Command\Command; |
|
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
8
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
9
|
|
|
use ZendDiagnostics\Check\AbstractCheck; |
|
10
|
|
|
use ZendDiagnostics\Result\Failure; |
|
11
|
|
|
use ZendDiagnostics\Result\ResultInterface; |
|
12
|
|
|
use ZendDiagnostics\Result\Success; |
|
13
|
|
|
|
|
14
|
|
|
class CheckCommand extends AbstractCheck |
|
15
|
|
|
{ |
|
16
|
|
|
/** @var Command */ |
|
17
|
|
|
private $command; |
|
18
|
|
|
|
|
19
|
|
|
/** @var InputInterface */ |
|
20
|
|
|
private $input; |
|
21
|
|
|
|
|
22
|
|
|
/** @var OutputInterface */ |
|
23
|
|
|
private $output; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* CheckSchema constructor. |
|
27
|
|
|
* @param Command $command |
|
28
|
|
|
* @param InputInterface $input |
|
29
|
|
|
* @param OutputInterface $output |
|
30
|
|
|
*/ |
|
31
|
|
|
public function __construct(Command $command, InputInterface $input, OutputInterface $output) |
|
32
|
|
|
{ |
|
33
|
|
|
$this->command = $command; |
|
34
|
|
|
$this->input = $input; |
|
35
|
|
|
$this->output = $output; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Perform the actual check and return a ResultInterface |
|
40
|
|
|
* |
|
41
|
|
|
* @return ResultInterface |
|
42
|
|
|
* @throws \Exception |
|
43
|
|
|
*/ |
|
44
|
|
|
public function check() |
|
45
|
|
|
{ |
|
46
|
|
|
$exitCode = $this->command->run($this->input, $this->output); |
|
47
|
|
|
|
|
48
|
|
|
$data = []; |
|
49
|
|
|
if ($this->output instanceof PropertyOutput) { |
|
50
|
|
|
$data = $this->output->getMessage(); |
|
51
|
|
|
if (!is_array($data)) { |
|
52
|
|
|
$data = explode(PHP_EOL, trim($data)); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
if ($exitCode < 1) { |
|
57
|
|
|
return new Success(get_class($this->command), $data); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
return new Failure(get_class($this->command), $data); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|