1
|
|
|
<?php |
2
|
|
|
namespace PressCLI\Command; |
3
|
|
|
|
4
|
|
|
use PressCLI\WPCLI\WP; |
5
|
|
|
use PressCLI\Command\PostInstall; |
6
|
|
|
use PressCLI\Option\Configuration; |
7
|
|
|
use PressCLI\Exception\ConfigurationNotFound; |
8
|
|
|
use Symfony\Component\Console\Command\Command; |
9
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
10
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
11
|
|
|
|
12
|
|
|
class InstallCommand extends Command |
13
|
|
|
{ |
14
|
|
|
protected function configure() |
15
|
|
|
{ |
16
|
|
|
$this->setName('install') |
17
|
|
|
->setDescription('Installs WordPress, required plugins, theme and dependencies'); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
21
|
|
|
{ |
22
|
|
|
// Make sure the configuration exists. |
23
|
|
|
if (!Configuration::exists()) { |
24
|
|
|
throw new ConfigurationNotFound; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
$output->writeln("<info>== Running Pre-install Commands =======================</info>"); |
28
|
|
|
|
29
|
|
|
// Run pre-install commands. |
30
|
|
|
PreInstall::executeCommands(); |
31
|
|
|
|
32
|
|
|
$output->writeln("\n<info>== Installing WordPress =======================</info>"); |
33
|
|
|
|
34
|
|
|
// Check/Download WordPress |
35
|
|
|
WP::coreDownload(); |
36
|
|
|
|
37
|
|
|
// Check/Create wp-config.php |
38
|
|
|
WP::coreConfig(); |
39
|
|
|
|
40
|
|
|
// Check/Create database |
41
|
|
|
WP::dbCreate(); |
42
|
|
|
|
43
|
|
|
// Check/Run install |
44
|
|
|
WP::coreInstall(); |
45
|
|
|
|
46
|
|
|
$output->writeln("\n<info>== Setting up Theme =======================</info>"); |
47
|
|
|
|
48
|
|
|
// Delete default themes (Except latest) |
49
|
|
|
WP::themeDeleteDefaults(); |
50
|
|
|
$output->writeln(''); |
51
|
|
|
|
52
|
|
|
// Check/Download/Merge theme (Zip/Tar/Git/Other?) |
53
|
|
|
WP::themeInstall($output); |
54
|
|
|
|
55
|
|
|
$output->writeln("\n<info>== Running Post Theme Install Commands =======================</info>"); |
56
|
|
|
|
57
|
|
|
// Run post install theme commands. |
58
|
|
|
PostInstall::executeThemeCommands(); |
59
|
|
|
|
60
|
|
|
$output->writeln("\n<info>== Setting up plugins =======================</info>"); |
61
|
|
|
|
62
|
|
|
// Remove default plugins |
63
|
|
|
WP::pluginDeleteDefaults(); |
64
|
|
|
$output->writeln(''); |
65
|
|
|
|
66
|
|
|
// Install wp.org plugins |
67
|
|
|
WP::pluginInstallAll($output); |
68
|
|
|
|
69
|
|
|
$output->writeln("\n<info>== Cleaning up default posts =======================</info>"); |
70
|
|
|
|
71
|
|
|
// Remove default posts |
72
|
|
|
WP::postDeleteDefault(); |
73
|
|
|
|
74
|
|
|
$output->writeln("\n<info>== Setting up menus =======================</info>"); |
75
|
|
|
|
76
|
|
|
// Create menus from theme menu locations? |
77
|
|
|
WP::menuCreateAll(); |
78
|
|
|
|
79
|
|
|
$output->writeln("\n<info>== Setting Permalink Structure =======================</info>"); |
80
|
|
|
|
81
|
|
|
// Set rewrite rules |
82
|
|
|
WP::rewriteSetStructure(); |
83
|
|
|
|
84
|
|
|
$output->writeln("\n<info>== Running Post Install Commands =======================</info>"); |
85
|
|
|
|
86
|
|
|
// Run post install commands. |
87
|
|
|
PostInstall::executeCommands(); |
88
|
|
|
|
89
|
|
|
$output->writeln("\n<info>Install Completed!</info>"); |
90
|
|
|
|
91
|
|
|
// Clean up the configuration for VCS. |
92
|
|
|
Configuration::cleanUpConfigForVCS(); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|