From 1fed340793cfb744c89517eb32f3855c72736187 Mon Sep 17 00:00:00 2001 From: Guilherme Blanco Date: Thu, 16 Jun 2011 19:54:50 -0300 Subject: [PATCH] Optimized AnnotationDriver to filter found files during getAllClassnames(). --- .../ORM/Mapping/Driver/AnnotationDriver.php | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php index cbf06fe7b..e30b9bf01 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php @@ -495,18 +495,20 @@ class AnnotationDriver implements Driver throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path); } - $iterator = new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator($path), - \RecursiveIteratorIterator::LEAVES_ONLY + $iterator = new \RegexIterator( + new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS), + \RecursiveIteratorIterator::LEAVES_ONLY + ), + '/^.+\\' . $this->_fileExtension . '$/i', + \RecursiveRegexIterator::GET_MATCH ); - + foreach ($iterator as $file) { - if (($fileName = $file->getBasename($this->_fileExtension)) == $file->getBasename()) { - continue; - } - - $sourceFile = realpath($file->getPathName()); + $sourceFile = realpath($file[0]); + require_once $sourceFile; + $includedFiles[] = $sourceFile; } }