public static function registerDirectory($dirName)
 {
     $di = new DirectoryIterator($dirName);
     foreach ($di as $file) {
         if ($file->isDir() && !$file->isLink() && !$file->isDot()) {
             // recurse into directories other than a few special ones
             self::registerDirectory($file->getPathname());
         } elseif (substr($file->getFilename(), -4) === '.php') {
             $className = self::getFullNamespacedName($file->getPathName());
             AutoLoader::registerClass($className, $file->getPathname());
         }
     }
 }
Beispiel #2
0
 /**
  * Store the filename (sans extension) & full path of all ".php" files found
  */
 public static function registerDirectory($dirName)
 {
     $di = new DirectoryIterator($dirName);
     foreach ($di as $file) {
         if ($file->isDir() && !$file->isLink() && !$file->isDot()) {
             // recurse into directories other than a few special ones
             self::registerDirectory($file->getPathname());
         } elseif (substr($file->getFilename(), -4) === '.php') {
             // save the class name / path of a .php file found
             $className = toCamelCase(substr($file->getFilename(), 0, -4));
             AutoLoader::registerClass($className, $file->getPathname());
         }
     }
 }
Beispiel #3
0
 /**
  * Store the filename (sans extension) & full path of all ".php" files found
  */
 public static function registerDirectory($dirName, $namespace = '')
 {
     $di = new DirectoryIterator($dirName);
     foreach ($di as $file) {
         /** @var DirectoryIterator $file */
         if ($file->isDir() && !$file->isLink() && !$file->isDot()) {
             // recurse into directories other than a few special ones
             self::registerDirectory($file->getPathname(), (empty($namespace) ? '' : $namespace . '\\') . $file->getBasename());
         } elseif (substr($file->getFilename(), -4) === '.php') {
             // save the class name / path of a .php file found
             $className = substr($file->getFilename(), 0, -4);
             AutoLoader::registerClass($className, $file->getPathname(), $namespace);
         }
     }
 }
 public static function registerDirectory($dirName, $mainDir = '')
 {
     $di = new \DirectoryIterator($dirName);
     if (empty($mainDir)) {
         $mainDir = $dirName;
     }
     foreach ($di as $file) {
         if ($file->isDir() && !$file->isLink() && !$file->isDot()) {
             self::registerDirectory($file->getPathname(), $mainDir);
         } elseif (substr($file->getFilename(), -4) === '.php') {
             $namespace = 'Mautic' . str_replace('/', '\\', substr(str_replace($mainDir, '', $file->getPathname()), 0, -4));
             AutoLoader::registerClass($namespace, $file->getPathname());
         }
     }
 }
Beispiel #5
0
 /**
  * Store the filename (sans extension) & full path of all ".php" files found
  */
 public static function registerDirectory($dirName)
 {
     $di = new DirectoryIterator($dirName);
     foreach ($di as $file) {
         if ($file->isDir() && !$file->isLink() && !$file->isDot()) {
             // recurse into directories other than a few special ones
             self::registerDirectory($file->getPathname());
         } else {
             if (substr($file->getFilename(), -4) === '.php') {
                 // save the class name / path of a .php file found
                 $className = substr($file->getFilename(), 0, -4);
                 //strip off .class if class files are named with a .class.php extension
                 if (substr($className, -6) === '.class') {
                     $className = substr($className, 0, -6);
                 }
                 //echo "Registering for auto load: [$className][" . $file->getPathname() . "]\n";
                 AutoLoader::registerClass($className, $file->getPathname());
             }
         }
     }
 }
 /**
  * Store the filename (sans extension) & full path of all ".php" files found
  */
 public static function registerDirectory($dirName)
 {
     $di = new DirectoryIterator($dirName);
     foreach ($di as $file) {
         if ($file->isDir() && !$file->isLink() && !$file->isDot()) {
             // recurse into directories other than a few special ones
             self::registerDirectory($file->getPathname());
         } elseif (preg_match('/[Aa]bstract\\.class/', $file->getFilename()) && substr($file->getFilename(), -19) === '.abstract.class.php') {
             //cs_version.abstract.class.php becomes "cs_versionAbstract"
             $className = preg_replace('/.abstract.class.php/', '', $file->getFilename()) . "Abstract";
             AutoLoader::registerClass($className, $file->getPathname());
         } elseif (substr($file->getFilename(), -10) === '.class.php') {
             $className = preg_replace('/.class.php/', '', $file->getFilename());
             #substr($file->getFilename(), 0, -10);
             AutoLoader::registerClass($className, $file->getPathname());
         } elseif (substr($file->getFilename(), -4) === '.php') {
             // save the class name / path of a .php file found
             $className = substr($file->getFilename(), 0, -4);
             AutoLoader::registerClass($className, $file->getPathname());
         }
     }
 }
Beispiel #7
0
 /**
  * @covers AutoLoader::registerClass
  */
 public function testRegisterClass()
 {
     $this->assertTrue(AutoLoader::registerClass('TestClassName', 'TestClassName.php'));
 }
 /**
  * Store the filename (sans extension) & full path of all ".php" files found.
  *
  * NOTE: This method will not be able to differentiate the same class names in different
  *       namespaces and will therefore overwrite class names if multiple of the same name is
  *       found. If possible, use registerNamespace instead!
  *
  * @param string $dirName
  * @return void
  */
 public static function registerDirectory($dirName)
 {
     $directoryContents = new \DirectoryIterator($dirName);
     foreach ($directoryContents as $file) {
         if ($file->isDir() && !$file->isLink() && !$file->isDot()) {
             // Recurse into directories other than a few special ones.
             static::registerDirectory($file->getPathname());
         } elseif (substr($file->getFilename(), -4) === '.php') {
             // Save the class name / path of a .php file found.
             $className = substr($file->getFilename(), 0, -4);
             AutoLoader::registerClass($className, $file->getPathname());
         }
     }
 }