|
1
|
|
|
<?php |
|
2
|
|
|
namespace Kunstmaan\Skylab\Command; |
|
3
|
|
|
|
|
4
|
|
|
use Kunstmaan\Skylab\Skeleton\AbstractSkeleton; |
|
5
|
|
|
use Kunstmaan\Skylab\Skeleton\BaseSkeleton; |
|
6
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* MaintenanceCommand |
|
10
|
|
|
*/ |
|
11
|
|
|
class MaintenanceCommand extends AbstractCommand |
|
12
|
|
|
{ |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Configures the current command. |
|
16
|
|
|
*/ |
|
17
|
|
|
protected function configure() |
|
18
|
|
|
{ |
|
19
|
|
|
$this |
|
20
|
|
|
->addDefaults() |
|
21
|
|
|
->setName('maintenance') |
|
22
|
|
|
->setDescription('Run maintenance on all Skylab projects') |
|
23
|
|
|
->addOption("--quick", null, InputOption::VALUE_NONE, 'If set, no fixperms will be executed') |
|
24
|
|
|
->setHelp(<<<EOT |
|
25
|
|
|
The <info>maintenance</info> command will run the maintenance commands of all skeletons on a project. Most notably, it |
|
26
|
|
|
will create the apache config files and make sure the the databases are available. |
|
27
|
|
|
|
|
28
|
|
|
<info>php skylab.phar maintenance</info> |
|
29
|
|
|
|
|
30
|
|
|
EOT |
|
31
|
|
|
); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* |
|
36
|
|
|
*/ |
|
37
|
|
|
protected function doExecute() |
|
38
|
|
|
{ |
|
39
|
|
|
$this->dialogProvider->logStep("Running preMaintenance"); |
|
40
|
|
|
$this->skeletonProvider->skeletonLoop(function (AbstractSkeleton $theSkeleton) { |
|
41
|
|
|
$this->dialogProvider->logTask("Running preMaintenance for skeleton " . $theSkeleton->getName()); |
|
42
|
|
|
$theSkeleton->preMaintenance(); |
|
43
|
|
|
}); |
|
44
|
|
|
|
|
45
|
|
|
$this->fileSystemProvider->projectsLoop(function ($project) { |
|
46
|
|
|
$this->dialogProvider->logStep("Running maintenance on " . $project["name"]); |
|
47
|
|
|
$this->skeletonProvider->skeletonLoop(function (AbstractSkeleton $theSkeleton) use ($project) { |
|
48
|
|
|
$this->dialogProvider->logTask("Running maintenance for skeleton " . $theSkeleton->getName()); |
|
49
|
|
|
$theSkeleton->maintenance($project); |
|
50
|
|
|
}, new \ArrayObject($project["skeletons"])); |
|
51
|
|
|
}); |
|
52
|
|
|
|
|
53
|
|
|
$this->dialogProvider->logStep("Running postMaintenance"); |
|
54
|
|
|
$this->skeletonProvider->skeletonLoop(function (AbstractSkeleton $theSkeleton) { |
|
55
|
|
|
$this->dialogProvider->logTask("Running postMaintenance for skeleton " . $theSkeleton->getName()); |
|
56
|
|
|
$theSkeleton->postMaintenance(); |
|
57
|
|
|
}); |
|
58
|
|
|
|
|
59
|
|
|
if (!$this->input->getOption('quick')) { |
|
60
|
|
|
$this->fileSystemProvider->projectsLoop(function ($project) { |
|
61
|
|
|
$this->dialogProvider->logStep("Running fixperms on " . $project["name"]); |
|
62
|
|
|
/** @var BaseSkeleton $abstractSkeleton */ |
|
63
|
|
|
$abstractSkeleton = $this->skeletonProvider->findSkeleton('base'); |
|
64
|
|
|
$abstractSkeleton->setPermissions(new \ArrayObject($project)); |
|
65
|
|
|
}); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|