summaryrefslogtreecommitdiffstats
path: root/lib/autoloader.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-05-07 22:19:00 +0200
committerRobin Appelman <icewind@owncloud.com>2013-05-07 22:19:00 +0200
commit19cfe74bf5d74c6f761513baf60da9ef7945f30e (patch)
tree0a0f31881b03b6e1a94fe771122b646573adc86f /lib/autoloader.php
parent0b5f6b9c13f5516c2d16fb938e77c9168a74b76d (diff)
downloadnextcloud-server-19cfe74bf5d74c6f761513baf60da9ef7945f30e.tar.gz
nextcloud-server-19cfe74bf5d74c6f761513baf60da9ef7945f30e.zip
Add per-autoloader classPath
Diffstat (limited to 'lib/autoloader.php')
-rw-r--r--lib/autoloader.php27
1 files changed, 24 insertions, 3 deletions
diff --git a/lib/autoloader.php b/lib/autoloader.php
index 27052e60a79..091c4de9674 100644
--- a/lib/autoloader.php
+++ b/lib/autoloader.php
@@ -9,13 +9,34 @@
namespace OC;
class Autoloader {
+ private $classPaths = array();
+
+ /**
+ * Add a custom classpath to the autoloader
+ *
+ * @param string $class
+ * @param string $path
+ */
+ public function registerClass($class, $path) {
+ $this->classPaths[$class] = $path;
+ }
+
+ /**
+ * Load the specified class
+ *
+ * @param string $class
+ * @return bool
+ */
public function load($class) {
$class = trim($class, '\\');
- if (array_key_exists($class, \OC::$CLASSPATH)) {
+ if (array_key_exists($class, $this->classPaths)) {
+ $path = $this->classPaths[$class];
+ } else if (array_key_exists($class, \OC::$CLASSPATH)) {
$path = \OC::$CLASSPATH[$class];
- /** @TODO: Remove this when necessary
- Remove "apps/" from inclusion path for smooth migration to mutli app dir
+ /**
+ * @TODO: Remove this when necessary
+ * Remove "apps/" from inclusion path for smooth migration to mutli app dir
*/
if (strpos($path, 'apps/') === 0) {
\OC_Log::write('core', 'include path for class "' . $class . '" starts with "apps/"', \OC_Log::DEBUG);