summaryrefslogtreecommitdiffstats
path: root/lib/private/repair.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/repair.php')
-rw-r--r--lib/private/repair.php40
1 files changed, 30 insertions, 10 deletions
diff --git a/lib/private/repair.php b/lib/private/repair.php
index 779f09d42ec..28fe993db07 100644
--- a/lib/private/repair.php
+++ b/lib/private/repair.php
@@ -46,20 +46,24 @@ use OC\Repair\RepairMimeTypes;
use OC\Repair\SearchLuceneTables;
use OC\Repair\UpdateOutdatedOcsIds;
use OC\Repair\RepairInvalidShares;
+use Symfony\Component\EventDispatcher\EventDispatcher;
+use Symfony\Component\EventDispatcher\GenericEvent;
class Repair extends BasicEmitter {
- /**
- * @var RepairStep[]
- **/
+ /* @var RepairStep[] */
private $repairSteps;
+ /** @var EventDispatcher */
+ private $dispatcher;
/**
* Creates a new repair step runner
*
- * @param array $repairSteps array of RepairStep instances
+ * @param RepairStep[] $repairSteps array of RepairStep instances
+ * @param EventDispatcher $dispatcher
*/
- public function __construct($repairSteps = array()) {
+ public function __construct($repairSteps = [], EventDispatcher $dispatcher = null) {
$this->repairSteps = $repairSteps;
+ $this->dispatcher = $dispatcher;
}
/**
@@ -91,10 +95,24 @@ class Repair extends BasicEmitter {
/**
* Add repair step
*
- * @param RepairStep $repairStep repair step
+ * @param RepairStep|string $repairStep repair step
+ * @throws \Exception
*/
public function addStep($repairStep) {
- $this->repairSteps[] = $repairStep;
+ if (is_string($repairStep)) {
+ if (class_exists($repairStep)) {
+ $s = new $repairStep();
+ if ($s instanceof RepairStep) {
+ $this->repairSteps[] = $s;
+ } else {
+ throw new \Exception("Repair step '$repairStep' is not of type \\OC\\RepairStep");
+ }
+ } else {
+ throw new \Exception("Repair step '$repairStep' is unknown");
+ }
+ } else {
+ $this->repairSteps[] = $repairStep;
+ }
}
/**
@@ -159,10 +177,12 @@ class Repair extends BasicEmitter {
/**
* {@inheritDoc}
- *
- * Re-declared as public to allow invocation from within the closure above in php 5.3
*/
- public function emit($scope, $method, array $arguments = array()) {
+ public function emit($scope, $method, array $arguments = []) {
parent::emit($scope, $method, $arguments);
+ if (!is_null($this->dispatcher)) {
+ $this->dispatcher->dispatch("$scope::$method",
+ new GenericEvent("$scope::$method", $arguments));
+ }
}
}