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 UninstallCommandExecutor { |
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->startRemoval(); |
23
|
|
|
|
24
|
|
|
try { |
25
|
|
|
$this->establishDatabaseConnection(); |
26
|
|
|
|
27
|
|
|
$this->removeDumpStore(); |
28
|
|
|
$this->removeTermStore(); |
29
|
|
|
$this->removeQueryEngine(); |
30
|
|
|
|
31
|
|
|
$this->reportRemovalSuccess(); |
32
|
|
|
} |
33
|
|
|
catch ( InstallationException $ex ) { |
34
|
|
|
$this->reportUninstallationFailure( $ex->getMessage() ); |
35
|
|
|
} |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
private function removeDumpStore() { |
39
|
|
|
$this->tryTask( |
40
|
|
|
'Removing dump store', |
41
|
|
|
function() { |
42
|
|
|
$this->factory->newEntityStoreInstaller()->uninstall(); |
43
|
|
|
} |
44
|
|
|
); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
private function removeTermStore() { |
48
|
|
|
$this->tryTask( |
49
|
|
|
'Removing term store', |
50
|
|
|
function() { |
51
|
|
|
$this->factory->newTermStoreInstaller()->uninstall(); |
52
|
|
|
} |
53
|
|
|
); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
private function removeQueryEngine() { |
57
|
|
|
if ( defined( 'WIKIBASE_QUERYENGINE_VERSION' ) ) { |
58
|
|
|
$this->tryTask( |
59
|
|
|
'Removing query engine', |
60
|
|
|
function() { |
61
|
|
|
$this->factory->newQueryEngineUninstaller()->uninstall(); |
62
|
|
|
} |
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
private function startRemoval() { |
68
|
|
|
$this->output->writeln( '<info>Uninstalling QueryR Replicator.</info>' ); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
private function reportUninstallationFailure( $failureMessage ) { |
72
|
|
|
$this->writeProgressEnd( 'failed!' ); |
73
|
|
|
$this->writeError( 'Error! Removal of QueryR Replicator failed.' ); |
74
|
|
|
$this->writeError( 'Reason: ' . $failureMessage ); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
private function reportRemovalSuccess() { |
78
|
|
|
$tag = 'bg=green;fg=black'; |
79
|
|
|
|
80
|
|
|
$this->output->writeln( |
81
|
|
|
"<$tag>Removal of QueryR Replicator has completed successfully.</$tag>" |
82
|
|
|
); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
} |
86
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.