From 53c5cf65e2a7adf62cb6fa46d1d3e082252aae63 Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Fri, 4 Jun 2010 16:03:27 -0400 Subject: [PATCH] New autoloader usage (add a Prefix mapper instead of the static addClassPattern() method) --- horde/rampage.php | 3 +-- ingo/lib/tests/AllTests.php | 4 ++-- koward/script/Koward/koward.php | 8 ++++---- koward/test/Koward/TestInit.php | 5 ++--- koward/www/htdocs/koward/koward.php | 8 ++++---- kronolith/lib/Application.php | 2 +- wicked/lib/Page.php | 4 ++-- 7 files changed, 16 insertions(+), 18 deletions(-) diff --git a/horde/rampage.php b/horde/rampage.php index ab71eb896..4c90b5a5e 100644 --- a/horde/rampage.php +++ b/horde/rampage.php @@ -62,8 +62,7 @@ include $routeFile; // Set up application class and controller loading // @TODO separate $app from class names so that there can be multiple instances // of an app in the registry? -Horde_Autoloader::addClassPattern('/^' . $app . '_/i', $fileroot . '/lib/'); -Horde_Autoloader::addClassPattern('/^' . $app . '_/i', $fileroot . '/app/controllers/'); +$injector->getInstance('Horde_Autoloader')->addClassPathMapper(new Horde_Autoloader_ClassPathMapper_Prefix('/^' . $app . '(?:$|_)/i', $fileroot . '/lib/')); // Create our controller context. $context = array( diff --git a/ingo/lib/tests/AllTests.php b/ingo/lib/tests/AllTests.php index a52b2569a..d42545dec 100644 --- a/ingo/lib/tests/AllTests.php +++ b/ingo/lib/tests/AllTests.php @@ -18,7 +18,7 @@ if (!defined('PHPUnit_MAIN_METHOD')) { * Prepare the test setup. */ @define('INGO_BASE', dirname(__FILE__) . '/../..'); -require_once 'Horde/Autoloader.php'; +require_once 'Horde/Core/Autoloader.php'; date_default_timezone_set('Europe/Berlin'); /** @@ -39,7 +39,7 @@ class Ingo_AllTests extends Horde_Test_AllTests // Set up autoload $basedir = dirname(__FILE__); - Horde_Autoloader::addClassPattern('/^Ingo(?:$|_)/', $basedir . '/../'); + $GLOBALS['__autoloader']->addClassPathMapper(new Horde_Autoloader_ClassPathMapper_Prefix('/^Ingo(?:$|_)/', $basedir . '/../')); $suite = new PHPUnit_Framework_TestSuite('Ingo'); $baseregexp = preg_quote($basedir . DIRECTORY_SEPARATOR, '/'); diff --git a/koward/script/Koward/koward.php b/koward/script/Koward/koward.php index 8b1e0c02c..c68cde901 100644 --- a/koward/script/Koward/koward.php +++ b/koward/script/Koward/koward.php @@ -3,7 +3,7 @@ /** * The Autoloader allows us to omit "require/include" statements. */ -require_once 'Horde/Autoloader.php'; +require_once 'Horde/Core/Autoloader.php'; /** * FIXME START @@ -46,10 +46,10 @@ require_once $opts->base . '/koward/config/base.php'; * FIXME END */ -/** Configure the Autoloader to handle the "Koward" pattern */ -Horde_Autoloader::addClassPattern('/^Koward_/', 'Koward/'); +/* Configure the Autoloader to handle the "Koward" pattern */ +$__autoloader->addClassPathMapper(new Horde_Autoloader_ClassPathMapper_Prefix('/^Koward_/', 'Koward/')); -/** Dispatch the request. */ +/* Dispatch the request. */ try { Koward::dispatch($opts->base . '/htdocs/koward/koward.php', 'Koward_Cli'); } catch (Exception $e) { diff --git a/koward/test/Koward/TestInit.php b/koward/test/Koward/TestInit.php index 8091e44c9..ac6ec3a59 100644 --- a/koward/test/Koward/TestInit.php +++ b/koward/test/Koward/TestInit.php @@ -14,12 +14,11 @@ /** * The Autoloader allows us to omit "require/include" statements. */ -require_once 'Horde/Autoloader.php'; +require_once 'Horde/Core/Autoloader.php'; if (!defined('KOWARD_BASE')) { define('KOWARD_BASE', dirname(__FILE__) . '/../'); } /* Set up the application class and controller loading */ -Horde_Autoloader::addClassPattern('/^Koward_/', KOWARD_BASE . '/lib/'); -Horde_Autoloader::addClassPattern('/^Koward_/', KOWARD_BASE . '/app/controllers/'); +$__autoloader->addClassPathMapper(new Horde_Autoloader_ClassPathMapper_Prefix('/^Koward_/', KOWARD_BASE . '/lib/')); diff --git a/koward/www/htdocs/koward/koward.php b/koward/www/htdocs/koward/koward.php index 38f9ed6ff..b7297109f 100644 --- a/koward/www/htdocs/koward/koward.php +++ b/koward/www/htdocs/koward/koward.php @@ -7,12 +7,12 @@ require_once dirname(__FILE__) . '/../../koward/config/base.php'; /** * The Autoloader allows us to omit "require/include" statements. */ -require_once 'Horde/Autoloader.php'; +require_once 'Horde/Core/Autoloader.php'; -/** Configure the Autoloader to handle the "Koward" pattern */ -Horde_Autoloader::addClassPattern('/^Koward_/', 'Koward/'); +/* Configure the Autoloader to handle the "Koward" pattern */ +$__autoloader->addClassPathMapper(new Horde_Autoloader_ClassPathMapper_Prefix('/^Koward_/', 'Koward/')); -/** Dispatch the request. */ +/* Dispatch the request. */ try { Koward::dispatch(__FILE__); } catch (Exception $e) { diff --git a/kronolith/lib/Application.php b/kronolith/lib/Application.php index 6bcca8c51..63c970906 100644 --- a/kronolith/lib/Application.php +++ b/kronolith/lib/Application.php @@ -59,7 +59,7 @@ class Kronolith_Application extends Horde_Registry_Application /* For now, autoloading the Content_* classes depend on there being a * registry entry for the 'content' application that contains at least * the fileroot entry. */ - Horde_Autoloader::addClassPattern('/^Content_/', $GLOBALS['registry']->get('fileroot', 'content') . '/lib/'); + $GLOBALS['injector']->getInstance('Horde_Autoloader')->addClassPathMapper(new Horde_Autoloader_ClassPathMapper_Prefix('/^Content_/', $GLOBALS['registry']->get('fileroot', 'content') . '/lib/')); if (!class_exists('Content_Tagger')) { throw new Horde_Exception('The Content_Tagger class could not be found. Make sure the registry entry for the Content system is present.'); } diff --git a/wicked/lib/Page.php b/wicked/lib/Page.php index 538c7df9f..785cba967 100644 --- a/wicked/lib/Page.php +++ b/wicked/lib/Page.php @@ -479,10 +479,10 @@ class Page { 'css_td' => 'table-cell', 'css_th' => 'table-cell')); - Horde_Autoloader::addClassPattern('/^Text_Wiki_Render_Xhtml/', WICKED_BASE . '/lib/Text_Wiki/Render/Xhtml'); + $GLOBALS['injector']->getInstance('Horde_Autoloader')->addClassPathMapper(new Horde_Autoloader_ClassPathMapper_Prefix('/^Text_Wiki_Render_Xhtml/', WICKED_BASE . '/lib/Text_Wiki/Render/Xhtml')); } - Horde_Autoloader::addClassPattern('/^Text_Wiki_Parse/', WICKED_BASE . '/lib/Text_Wiki/Parse/' . $format); + $GLOBALS['injector']->getInstance('Horde_Autoloader')->addClassPathMapper(new Horde_Autoloader_ClassPathMapper_Prefix('/^Text_Wiki_Parse/', WICKED_BASE . '/lib/Text_Wiki/Parse/' . $format)); return $this->_proc; } -- 2.11.0