From 60c921762dbc93a2c573e4366ef26cad087c20f6 Mon Sep 17 00:00:00 2001 From: "Jonathan.Wage" Date: Sat, 5 Jan 2008 07:53:24 +0000 Subject: [PATCH] A few more fixes for autoloading and locating paths to Doctrine components. --- lib/Doctrine.php | 25 +++++++++++++++---------- lib/orm/Lib.php | 2 +- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/Doctrine.php b/lib/Doctrine.php index f390e566a..6e00f8db9 100644 --- a/lib/Doctrine.php +++ b/lib/Doctrine.php @@ -1075,17 +1075,9 @@ final class Doctrine self::$_path = dirname(__FILE__); } - $findPattern = self::$_path . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, str_replace('Doctrine_', '', $className)) . '.php'; - - $matches = glob($findPattern); - - if ( ! isset($matches[0])) { - return false; - } - - $class = $matches[0]; + $class = self::locate($className . '.php'); - if (file_exists($class)) { + if ($class && file_exists($class)) { require $class; return true; @@ -1101,6 +1093,19 @@ final class Doctrine return false; } + + public static function locate($name) + { + $findPattern = self::$_path . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, str_replace('Doctrine_', '', $name)); + + $matches = glob($findPattern); + + if ( isset($matches[0])) { + return $matches[0]; + } else { + return false; + } + } /** * dump diff --git a/lib/orm/Lib.php b/lib/orm/Lib.php index bd9a2ce6f..acdbf7860 100644 --- a/lib/orm/Lib.php +++ b/lib/orm/Lib.php @@ -329,7 +329,7 @@ class Doctrine_Lib { $validators = array(); - $dir = Doctrine::getPath() . DIRECTORY_SEPARATOR . 'Doctrine' . DIRECTORY_SEPARATOR . 'Validator'; + $dir = Doctrine::locate('Doctrine_Validator'); $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY); foreach ($files as $file) {