diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2015-11-06 13:36:19 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2015-11-06 13:36:19 +0100 |
commit | 0bb5eadf8984fbb21e9f573da9a37e4a75e83a68 (patch) | |
tree | 9a6f35cf75a0ee6e0bc1a010ba2757ef90458708 /lib/autoloader.php | |
parent | dc96aa384921dab74ea3aea07cbf016f8bd0681f (diff) | |
download | nextcloud-server-0bb5eadf8984fbb21e9f573da9a37e4a75e83a68.tar.gz nextcloud-server-0bb5eadf8984fbb21e9f573da9a37e4a75e83a68.zip |
[autoloader] Make sure to load construct full paths
This reduces a lot of the autoloader magic and makes sure that we
generate full paths in the autoloader.
Diffstat (limited to 'lib/autoloader.php')
-rw-r--r-- | lib/autoloader.php | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/lib/autoloader.php b/lib/autoloader.php index b91681946a5..f0fbd9e9f27 100644 --- a/lib/autoloader.php +++ b/lib/autoloader.php @@ -100,14 +100,30 @@ class Autoloader { $paths[] = str_replace('apps/', '', \OC::$CLASSPATH[$class]); } } elseif (strpos($class, 'OC_') === 0) { - // first check for legacy classes if underscores are used - $paths[] = 'private/legacy/' . strtolower(str_replace('_', '/', substr($class, 3)) . '.php'); - $paths[] = 'private/' . strtolower(str_replace('_', '/', substr($class, 3)) . '.php'); + $paths[] = \OC::$SERVERROOT . '/lib/private/legacy/' . strtolower(str_replace('_', '/', substr($class, 3)) . '.php'); + $paths[] = \OC::$SERVERROOT . '/lib/private/' . strtolower(str_replace('_', '/', substr($class, 3)) . '.php'); } elseif (strpos($class, 'OC\\') === 0) { - $paths[] = 'private/' . strtolower(str_replace('\\', '/', substr($class, 3)) . '.php'); - $paths[] = strtolower(str_replace('\\', '/', substr($class, 3)) . '.php'); + $split = explode('\\', $class, 3); + + if (count($split) === 3) { + $split[1] = strtolower($split[1]); + + if ($split[1] === 'core') { + $paths[] = \OC::$SERVERROOT . '/core/' . strtolower(str_replace('\\', '/', $split[2])) . '.php'; + } else if ($split[1] === 'settings') { + $paths[] = \OC::$SERVERROOT . '/settings/' . strtolower(str_replace('\\', '/', $split[2])) . '.php'; + } else if ($split[1] === 'repair') { + $paths[] = \OC::$SERVERROOT . '/lib/repair/' . strtolower(str_replace('\\', '/', $split[2])) . '.php'; + + } else { + $paths[] = \OC::$SERVERROOT . '/lib/private/' . $split[1] . '/' . strtolower(str_replace('\\', '/', $split[2])) . '.php'; + } + + } else { + $paths[] = \OC::$SERVERROOT . '/lib/private/' . strtolower(str_replace('\\', '/', $split[1])) . '.php'; + } } elseif (strpos($class, 'OCP\\') === 0) { - $paths[] = 'public/' . strtolower(str_replace('\\', '/', substr($class, 4)) . '.php'); + $paths[] = \OC::$SERVERROOT . '/lib/public/' . strtolower(str_replace('\\', '/', substr($class, 4)) . '.php'); } elseif (strpos($class, 'OCA\\') === 0) { list(, $app, $rest) = explode('\\', $class, 3); $app = strtolower($app); @@ -118,9 +134,9 @@ class Autoloader { $paths[] = $appPath . '/lib/' . strtolower(str_replace('\\', '/', $rest) . '.php'); } } elseif (strpos($class, 'Test_') === 0) { - $paths[] = 'tests/lib/' . strtolower(str_replace('_', '/', substr($class, 5)) . '.php'); + $paths[] = \OC::$SERVERROOT . '/tests/lib/' . strtolower(str_replace('_', '/', substr($class, 5)) . '.php'); } elseif (strpos($class, 'Test\\') === 0) { - $paths[] = 'tests/lib/' . strtolower(str_replace('\\', '/', substr($class, 5)) . '.php'); + $paths[] = \OC::$SERVERROOT . '/tests/lib/' . strtolower(str_replace('\\', '/', substr($class, 5)) . '.php'); } return $paths; } |