Good Morning, what do you think about the method written below? Could it be added to ezcBase? The motivation is to have a quick way to add extensions to the autoloader.
If you'd agree, to have this method included, I could also provide testcases. Cheers, Thomas Koch /** * adds specific subdirs of $baseDir as class repositories. * * If given only $baseDir, this method adds all subdirectories of $baseDir * as class repositories, as long as the subdirectories contains * themselves a directory named 'autoload'. * You can give a list of $subDirs so that the method only adds the given * $subDirs as long as they contain a directory named 'autoload'. * The directory name 'autoload' which indicates a class repository can be * overwritten with the parameter $requiredAutoloadDir. * * @see ezcBase::addClassRepository() * * @param string $baseDir * @param Array $subDirs * @param string $requiredAutoloadDir * @return void */ public static function addClassRepositories( $baseDir, Array $subDirs = NULL, $requiredAutoloadDir = NULL ) { if( NULL === $requiredAutoloadDir ) { $requiredAutoloadDir = 'autoload'; } // Well... This should evaluate to two different forms: // extensionDir/*/autoload or // extensionDir/{myextxyz,yourext,someext}/autoload // See http://www.php.net/manual/en/function.glob.php $autoloadDirs = glob( $baseDir.DIRECTORY_SEPARATOR .(NULL === $subDirs ? '*' : '{'.implode( $subDirs, ',' ).'}') .DIRECTORY_SEPARATOR .$requiredAutoloadDir, GLOB_BRACE | GLOB_ONLYDIR | GLOB_NOSORT ); // How much to cut to get the repository dir without trailing slash? $trimLength = -( strlen( $requiredAutoloadDir ) + 1 ); // add info to the list of extra dirs foreach( $autoloadDirs as $dir ) { ezcBase::$repositoryDirs[] = array( 'basePath' => substr( $dir, 0, $trimLength ), 'autoloadDirPath' => $dir ); } } -- Thomas Koch, Software Developer http://www.koch.ro -- Components mailing list Components@lists.ez.no http://lists.ez.no/mailman/listinfo/components