|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Queryr\Replicator\Cli\Install; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
6
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* @licence GNU GPL v2+ |
|
10
|
|
|
* @author Jeroen De Dauw < [email protected] > |
|
11
|
|
|
*/ |
|
12
|
|
|
class InstallCommandExecutor { |
|
13
|
|
|
use InstallerTrait; |
|
14
|
|
|
|
|
15
|
|
|
private $output; |
|
16
|
|
|
|
|
17
|
|
|
public function __construct( InputInterface $input, OutputInterface $output ) { |
|
|
|
|
|
|
18
|
|
|
$this->output = $output; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
public function run() { |
|
22
|
|
|
$this->startInstallation(); |
|
23
|
|
|
|
|
24
|
|
|
try { |
|
25
|
|
|
$this->establishDatabaseConnection(); |
|
26
|
|
|
$this->createDumpStore(); |
|
27
|
|
|
$this->createTermStore(); |
|
28
|
|
|
$this->createQueryEngine(); |
|
29
|
|
|
|
|
30
|
|
|
$this->reportInstallationSuccess(); |
|
31
|
|
|
} |
|
32
|
|
|
catch ( InstallationException $ex ) { |
|
33
|
|
|
$this->reportInstallationFailure( $ex->getMessage() ); |
|
34
|
|
|
} |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
private function startInstallation() { |
|
38
|
|
|
$this->output->writeln( '<info>Installing QueryR Replicator.</info>' ); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
private function createDumpStore() { |
|
42
|
|
|
$this->tryTask( |
|
43
|
|
|
'Creating dump store', |
|
44
|
|
|
function() { |
|
45
|
|
|
$this->factory->newEntityStoreInstaller()->install(); |
|
46
|
|
|
} |
|
47
|
|
|
); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
private function createTermStore() { |
|
51
|
|
|
$this->tryTask( |
|
52
|
|
|
'Creating term store', |
|
53
|
|
|
function() { |
|
54
|
|
|
$this->factory->newTermStoreInstaller()->install(); |
|
55
|
|
|
} |
|
56
|
|
|
); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
private function createQueryEngine() { |
|
60
|
|
|
if ( defined( 'WIKIBASE_QUERYENGINE_VERSION' ) ) { |
|
61
|
|
|
$this->tryTask( |
|
62
|
|
|
'Creating query engine', |
|
63
|
|
|
function () { |
|
64
|
|
|
$this->factory->newQueryEngineInstaller()->install(); |
|
65
|
|
|
} |
|
66
|
|
|
); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
private function reportInstallationFailure( $failureMessage ) { |
|
71
|
|
|
$this->writeProgressEnd( 'failed!' ); |
|
72
|
|
|
$this->writeError( 'Error! Installation of QueryR Replicator failed.' ); |
|
73
|
|
|
$this->writeError( 'Reason: ' . $failureMessage ); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
private function reportInstallationSuccess() { |
|
77
|
|
|
$tag = 'bg=green;fg=black'; |
|
78
|
|
|
|
|
79
|
|
|
$this->output->writeln( |
|
80
|
|
|
"<$tag>Installation of QueryR Replicator has completed successfully.</$tag>" |
|
81
|
|
|
); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
} |
|
85
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.