From 3969a6b1ebae547a575329fb53d61dc8dbffb217 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 2 Jun 2017 14:22:04 +0200 Subject: [PATCH] Use autoloading instead of require_once from a different dir Signed-off-by: Joas Schilling --- lib/private/DB/MigrationService.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php index c81fe0f433..65157299dd 100644 --- a/lib/private/DB/MigrationService.php +++ b/lib/private/DB/MigrationService.php @@ -58,7 +58,7 @@ class MigrationService { * @param IOutput|null $output * @throws \Exception */ - function __construct($appName, IDBConnection $connection, IOutput $output = null, AppLocator $appLocator = null) { + public function __construct($appName, IDBConnection $connection, IOutput $output = null, AppLocator $appLocator = null) { $this->appName = $appName; $this->connection = $connection; $this->output = $output; @@ -74,21 +74,16 @@ class MigrationService { $appLocator = new AppLocator(); } $appPath = $appLocator->getAppPath($appName); - $this->migrationsPath = "$appPath/appinfo/Migrations"; - $this->migrationsNamespace = "OCA\\$appName\\Migrations"; + $namespace = \OCP\AppFramework\App::buildAppNamespace($appName); + $this->migrationsPath = "$appPath/lib/Migration"; + $this->migrationsNamespace = $namespace . '\\Migration'; } - if (!is_dir($this->migrationsPath)) { - if (!mkdir($this->migrationsPath)) { - throw new \Exception("Could not create migration folder \"{$this->migrationsPath}\""); - }; + if (!is_dir($this->migrationsPath) && !mkdir($this->migrationsPath)) { + throw new \Exception("Could not create migration folder \"{$this->migrationsPath}\""); } } - private static function requireOnce($file) { - require_once $file; - } - /** * Returns the name of the app for which this migration is executed * @@ -180,7 +175,6 @@ class MigrationService { $migrations = []; foreach ($files as $file) { - static::requireOnce($file); $className = basename($file, '.php'); $version = (string) substr($className, 7); if ($version === '0') {