summaryrefslogtreecommitdiffstats
path: root/lib/autoloader.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-05-07 22:24:47 +0200
committerRobin Appelman <icewind@owncloud.com>2013-05-07 22:24:47 +0200
commitcac86bb4db670e868ae61aef176d229c814452c0 (patch)
tree45eae888e16cae893019161fe666bb608cf62e82 /lib/autoloader.php
parentd1fcb7eb5237d597a878e5f7b61693e7dee29ca8 (diff)
downloadnextcloud-server-cac86bb4db670e868ae61aef176d229c814452c0.tar.gz
nextcloud-server-cac86bb4db670e868ae61aef176d229c814452c0.zip
Allow disabling the global classpath in an autoloader
Diffstat (limited to 'lib/autoloader.php')
-rw-r--r--lib/autoloader.php22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/autoloader.php b/lib/autoloader.php
index 9547ddc7d91..94c0ac7cb5d 100644
--- a/lib/autoloader.php
+++ b/lib/autoloader.php
@@ -9,6 +9,8 @@
namespace OC;
class Autoloader {
+ private $useGlobalClassPath = true;
+
private $classPaths = array();
/**
@@ -22,6 +24,20 @@ class Autoloader {
}
/**
+ * disable the usage of the global classpath \OC::$CLASSPATH
+ */
+ public function disableGlobalClassPath() {
+ $this->useGlobalClassPath = false;
+ }
+
+ /**
+ * enable the usage of the global classpath \OC::$CLASSPATH
+ */
+ public function enableGlobalClassPath() {
+ $this->useGlobalClassPath = true;
+ }
+
+ /**
* Load the specified class
*
* @param string $class
@@ -33,15 +49,15 @@ class Autoloader {
$paths = array();
if (array_key_exists($class, $this->classPaths)) {
$paths[] = $this->classPaths[$class];
- } else if (array_key_exists($class, \OC::$CLASSPATH)) {
+ } else if ($this->useGlobalClassPath and array_key_exists($class, \OC::$CLASSPATH)) {
$paths[] = \OC::$CLASSPATH[$class];
/**
* @TODO: Remove this when necessary
* Remove "apps/" from inclusion path for smooth migration to mutli app dir
*/
- if (strpos($path, 'apps/') === 0) {
+ if (strpos(\OC::$CLASSPATH[$class], 'apps/') === 0) {
\OC_Log::write('core', 'include path for class "' . $class . '" starts with "apps/"', \OC_Log::DEBUG);
- $path = str_replace('apps/', '', $path);
+ $path = str_replace('apps/', '', \OC::$CLASSPATH[$class]);
}
} elseif (strpos($class, 'OC_') === 0) {
$paths[] = strtolower(str_replace('_', '/', substr($class, 3)) . '.php');