summaryrefslogtreecommitdiffstats
path: root/core/Command/Maintenance/Repair.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/Command/Maintenance/Repair.php')
-rw-r--r--core/Command/Maintenance/Repair.php96
1 files changed, 40 insertions, 56 deletions
diff --git a/core/Command/Maintenance/Repair.php b/core/Command/Maintenance/Repair.php
index 2a3d7a908e2..e1d1862f3f4 100644
--- a/core/Command/Maintenance/Repair.php
+++ b/core/Command/Maintenance/Repair.php
@@ -30,36 +30,31 @@ namespace OC\Core\Command\Maintenance;
use Exception;
use OCP\App\IAppManager;
+use OCP\EventDispatcher\Event;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
+use OC\Repair\Events\RepairAdvanceEvent;
+use OC\Repair\Events\RepairErrorEvent;
+use OC\Repair\Events\RepairFinishEvent;
+use OC\Repair\Events\RepairInfoEvent;
+use OC\Repair\Events\RepairStartEvent;
+use OC\Repair\Events\RepairStepEvent;
+use OC\Repair\Events\RepairWarningEvent;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Symfony\Component\EventDispatcher\GenericEvent;
class Repair extends Command {
- /** @var \OC\Repair $repair */
- protected $repair;
- /** @var IConfig */
- protected $config;
- /** @var EventDispatcherInterface */
- private $dispatcher;
- /** @var ProgressBar */
- private $progress;
- /** @var OutputInterface */
- private $output;
- /** @var IAppManager */
- private $appManager;
+ protected \OC\Repair $repair;
+ protected IConfig $config;
+ private IEventDispatcher $dispatcher;
+ private ProgressBar $progress;
+ private OutputInterface $output;
+ private IAppManager $appManager;
- /**
- * @param \OC\Repair $repair
- * @param IConfig $config
- * @param EventDispatcherInterface $dispatcher
- * @param IAppManager $appManager
- */
- public function __construct(\OC\Repair $repair, IConfig $config, EventDispatcherInterface $dispatcher, IAppManager $appManager) {
+ public function __construct(\OC\Repair $repair, IConfig $config, IEventDispatcher $dispatcher, IAppManager $appManager) {
$this->repair = $repair;
$this->config = $config;
$this->dispatcher = $dispatcher;
@@ -94,7 +89,7 @@ class Repair extends Command {
if (!$this->appManager->isEnabledForUser($app)) {
continue;
}
- $info = \OC_App::getAppInfo($app);
+ $info = $this->appManager->getAppInfo($app);
if (!is_array($info)) {
continue;
}
@@ -114,13 +109,13 @@ class Repair extends Command {
$this->progress = new ProgressBar($output);
$this->output = $output;
- $this->dispatcher->addListener('\OC\Repair::startProgress', [$this, 'handleRepairFeedBack']);
- $this->dispatcher->addListener('\OC\Repair::advance', [$this, 'handleRepairFeedBack']);
- $this->dispatcher->addListener('\OC\Repair::finishProgress', [$this, 'handleRepairFeedBack']);
- $this->dispatcher->addListener('\OC\Repair::step', [$this, 'handleRepairFeedBack']);
- $this->dispatcher->addListener('\OC\Repair::info', [$this, 'handleRepairFeedBack']);
- $this->dispatcher->addListener('\OC\Repair::warning', [$this, 'handleRepairFeedBack']);
- $this->dispatcher->addListener('\OC\Repair::error', [$this, 'handleRepairFeedBack']);
+ $this->dispatcher->addListener(RepairStartEvent::class, [$this, 'handleRepairFeedBack']);
+ $this->dispatcher->addListener(RepairAdvanceEvent::class, [$this, 'handleRepairFeedBack']);
+ $this->dispatcher->addListener(RepairFinishEvent::class, [$this, 'handleRepairFeedBack']);
+ $this->dispatcher->addListener(RepairStepEvent::class, [$this, 'handleRepairFeedBack']);
+ $this->dispatcher->addListener(RepairInfoEvent::class, [$this, 'handleRepairFeedBack']);
+ $this->dispatcher->addListener(RepairWarningEvent::class, [$this, 'handleRepairFeedBack']);
+ $this->dispatcher->addListener(RepairErrorEvent::class, [$this, 'handleRepairFeedBack']);
$this->repair->run();
@@ -128,33 +123,22 @@ class Repair extends Command {
return 0;
}
- public function handleRepairFeedBack($event) {
- if (!$event instanceof GenericEvent) {
- return;
- }
- switch ($event->getSubject()) {
- case '\OC\Repair::startProgress':
- $this->progress->start($event->getArgument(0));
- break;
- case '\OC\Repair::advance':
- $this->progress->advance($event->getArgument(0));
- break;
- case '\OC\Repair::finishProgress':
- $this->progress->finish();
- $this->output->writeln('');
- break;
- case '\OC\Repair::step':
- $this->output->writeln(' - ' . $event->getArgument(0));
- break;
- case '\OC\Repair::info':
- $this->output->writeln(' - ' . $event->getArgument(0));
- break;
- case '\OC\Repair::warning':
- $this->output->writeln(' - WARNING: ' . $event->getArgument(0));
- break;
- case '\OC\Repair::error':
- $this->output->writeln('<error> - ERROR: ' . $event->getArgument(0) . '</error>');
- break;
+ public function handleRepairFeedBack(Event $event): void {
+ if ($event instanceof RepairStartEvent) {
+ $this->progress->start($event->getMaxStep());
+ } elseif ($event instanceof RepairAdvanceEvent) {
+ $this->progress->advance($event->getIncrement());
+ } elseif ($event instanceof RepairFinishEvent) {
+ $this->progress->finish();
+ $this->output->writeln('');
+ } elseif ($event instanceof RepairStepEvent) {
+ $this->output->writeln('<info> - ' . $event->getStepName() . '</info>');
+ } elseif ($event instanceof RepairInfoEvent) {
+ $this->output->writeln('<info> - ' . $event->getMessage() . '</info>');
+ } elseif ($event instanceof RepairWarningEvent) {
+ $this->output->writeln('<comment> - WARNING: ' . $event->getMessage()) . '</comment>';
+ } elseif ($event instanceof RepairErrorEvent) {
+ $this->output->writeln('<error> - ERROR: ' . $event->getMessage() . '</error>');
}
}
}