Bootstrap the new autoloader and set it on the injector
authorChuck Hagenbuch <chuck@horde.org>
Fri, 4 Jun 2010 19:52:51 +0000 (15:52 -0400)
committerChuck Hagenbuch <chuck@horde.org>
Fri, 4 Jun 2010 20:14:33 +0000 (16:14 -0400)
framework/Core/lib/Horde/Core/Autoloader.php [new file with mode: 0644]
framework/Core/lib/Horde/Registry.php
framework/Core/package.xml
horde/lib/core.php

diff --git a/framework/Core/lib/Horde/Core/Autoloader.php b/framework/Core/lib/Horde/Core/Autoloader.php
new file mode 100644 (file)
index 0000000..39ffe0a
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+require_once 'Horde/Autoloader.php';
+require_once 'Horde/Autoloader/ClassPathMapper.php';
+require_once 'Horde/Autoloader/ClassPathMapper/Default.php';
+
+class Horde_Core_Autoloader extends Horde_Autoloader
+{
+    public function __construct()
+    {
+        foreach (array_reverse(explode(PATH_SEPARATOR, get_include_path())) as $path) {
+            if ($path == '.') { continue; }
+            $path = realpath($path);
+            if ($path) {
+                $this->addClassPathMapper(new Horde_Autoloader_ClassPathMapper_Default($path));
+            }
+        }
+    }
+}
+
+$__autoloader = new Horde_Core_Autoloader();
+$__autoloader->registerAutoloader();
index 33f0ee0..63d64ae 100644 (file)
@@ -294,6 +294,8 @@ class Horde_Registry
         $GLOBALS['registry'] = $this;
         $injector->setInstance('Horde_Registry', $this);
 
+        $injector->setInstance('Horde_Autoloader', $GLOBALS['__autoloader']);
+
         /* Initialize browser object. */
         $GLOBALS['browser'] = $injector->getInstance('Horde_Browser');
 
@@ -1075,7 +1077,7 @@ class Horde_Registry
          * be done here because it is possible to try to load app-specific
          * libraries from other applications. */
         $app_lib = $this->get('fileroot', $app) . '/lib';
-        Horde_Autoloader::addClassPattern('/^' . $app . '(?:$|_)/i', $app_lib);
+        $GLOBALS['injector']->getInstance('Horde_Autoloader')->addClassPathMapper(new Horde_Autoloader_ClassPathMapper_Prefix('/^' . $app . '(?:$|_)/i', $app_lib));
 
         $checkPerms = !isset($options['check_perms']) || !empty($options['check_perms']);
 
index de76dfa..714b299 100644 (file)
@@ -73,6 +73,7 @@ Application Framework.
        </dir> <!-- /lib/Horde/Core/Auth/Signup -->
        <file name="Signup.php" role="php" />
       </dir> <!-- /lib/Horde/Core/Auth -->
+      <file name="Autoloader.php" role="php" />
       <dir name="Autoloader">
        <dir name="Callback">
         <file name="Auth.php" role="php" />
@@ -272,6 +273,7 @@ Application Framework.
    <install name="lib/Horde/Core/Auth/Signup/Null.php" as="Horde/Core/Auth/Signup/Null.php" />
    <install name="lib/Horde/Core/Auth/Signup/Sql.php" as="Horde/Core/Auth/Signup/Sql.php" />
    <install name="lib/Horde/Core/Auth/Signup/SqlObject.php" as="Horde/Core/Auth/Signup/SqlObject.php" />
+   <install name="lib/Horde/Core/Autoloader.php" as="Horde/Core/Autoloader.php" />
    <install name="lib/Horde/Core/Autoloader/Callback/Auth.php" as="Horde/Core/Autoloader/Callback/Auth.php" />
    <install name="lib/Horde/Core/Autoloader/Callback/Mime.php" as="Horde/Core/Autoloader/Callback/Mime.php" />
    <install name="lib/Horde/Core/Binder/Alarm.php" as="Horde/Core/Binder/Alarm.php" />
index bec984a..9d110af 100644 (file)
@@ -37,8 +37,8 @@ if (file_exists(HORDE_BASE . '/config/horde.local.php')) {
 /* Set up autoload paths for core Horde libs (located in lib/). This can't
  * be defined in Horde_Autoloader since the current directory path can not be
  * determined there. */
-require_once 'Horde/Autoloader.php';
-Horde_Autoloader::addClassPattern('/^Horde(?:$|_)/i', $dirname);
+require_once 'Horde/Core/Autoloader.php';
+$__autoloader->addClassPathMapper(new Horde_Autoloader_ClassPathMapper_Prefix('/^Horde(?:$|_)/i', $dirname));
 
 /* Default exception handler for uncaught exceptions. The default fatal
  * exception handler output may include things like passwords, etc. so don't