Merge pull request #24419 from owncloud/allow-di-for-migration-steps

Allow migration steps to use automatic DI
This commit is contained in:
Thomas Müller 2016-05-09 09:56:56 +02:00
commit a502de0d28
1 changed files with 12 additions and 7 deletions

View File

@ -28,7 +28,6 @@
namespace OC; namespace OC;
use OC\Hooks\Emitter;
use OC\Repair\AssetCache; use OC\Repair\AssetCache;
use OC\Repair\CleanTags; use OC\Repair\CleanTags;
use OC\Repair\Collation; use OC\Repair\Collation;
@ -45,6 +44,7 @@ use OC\Repair\RepairMimeTypes;
use OC\Repair\SearchLuceneTables; use OC\Repair\SearchLuceneTables;
use OC\Repair\UpdateOutdatedOcsIds; use OC\Repair\UpdateOutdatedOcsIds;
use OC\Repair\RepairInvalidShares; use OC\Repair\RepairInvalidShares;
use OCP\AppFramework\QueryException;
use OCP\Migration\IOutput; use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep; use OCP\Migration\IRepairStep;
use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\EventDispatcher;
@ -93,15 +93,20 @@ class Repair implements IOutput{
*/ */
public function addStep($repairStep) { public function addStep($repairStep) {
if (is_string($repairStep)) { if (is_string($repairStep)) {
if (class_exists($repairStep)) { try {
$s = new $repairStep(); $s = \OC::$server->query($repairStep);
if ($s instanceof IRepairStep) { } catch (QueryException $e) {
$this->repairSteps[] = $s; if (class_exists($repairStep)) {
$s = new $repairStep();
} else { } else {
throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep"); throw new \Exception("Repair step '$repairStep' is unknown");
} }
}
if ($s instanceof IRepairStep) {
$this->repairSteps[] = $s;
} else { } else {
throw new \Exception("Repair step '$repairStep' is unknown"); throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep");
} }
} else { } else {
$this->repairSteps[] = $repairStep; $this->repairSteps[] = $repairStep;