Allow migration steps to use automatic DI
This commit is contained in:
parent
adf7e7295e
commit
dda949e915
|
@ -28,7 +28,6 @@
|
|||
|
||||
namespace OC;
|
||||
|
||||
use OC\Hooks\Emitter;
|
||||
use OC\Repair\AssetCache;
|
||||
use OC\Repair\CleanTags;
|
||||
use OC\Repair\Collation;
|
||||
|
@ -45,6 +44,7 @@ use OC\Repair\RepairMimeTypes;
|
|||
use OC\Repair\SearchLuceneTables;
|
||||
use OC\Repair\UpdateOutdatedOcsIds;
|
||||
use OC\Repair\RepairInvalidShares;
|
||||
use OCP\AppFramework\QueryException;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\IRepairStep;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
|
@ -93,16 +93,21 @@ class Repair implements IOutput{
|
|||
*/
|
||||
public function addStep($repairStep) {
|
||||
if (is_string($repairStep)) {
|
||||
try {
|
||||
$s = \OC::$server->query($repairStep);
|
||||
} catch (QueryException $e) {
|
||||
if (class_exists($repairStep)) {
|
||||
$s = new $repairStep();
|
||||
} else {
|
||||
throw new \Exception("Repair step '$repairStep' is unknown");
|
||||
}
|
||||
}
|
||||
|
||||
if ($s instanceof IRepairStep) {
|
||||
$this->repairSteps[] = $s;
|
||||
} else {
|
||||
throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep");
|
||||
}
|
||||
} else {
|
||||
throw new \Exception("Repair step '$repairStep' is unknown");
|
||||
}
|
||||
} else {
|
||||
$this->repairSteps[] = $repairStep;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue