Alternc  latest
Alternc logiel libre pour l'hébergement
AutoLoader.php
Go to the documentation of this file.
1 <?php
2 class AutoLoader {
3 
4  static private $classNames = array();
5 
6  /**
7  * Store the filename (sans extension) & full path of all ".php" files found
8  */
9  public static function registerDirectory($dirName) {
10 
11  $di = new DirectoryIterator($dirName);
12  foreach ($di as $file) {
13 
14  if ($file->isDir() && !$file->isLink() && !$file->isDot()) {
15  // recurse into directories other than a few special ones
16  self::registerDirectory($file->getPathname());
17  } elseif (substr($file->getFilename(), -4) === '.php') {
18  // save the class name / path of a .php file found
19  $className = substr($file->getFilename(), 0, -4);
20  AutoLoader::registerClass($className, $file->getPathname());
21  }
22  }
23  }
24 
25  /**
26  * @param string $className
27  * @param string $fileName
28  */
29  public static function registerClass($className, $fileName) {
30  AutoLoader::$classNames[$className] = $fileName;
31  }
32 
33  public static function loadClass($className) {
34  if (isset(AutoLoader::$classNames[$className])) {
35  require_once(AutoLoader::$classNames[$className]);
36  }
37  }
38 
39 }
40 
41 spl_autoload_register(array('AutoLoader', 'loadClass'));
static loadClass($className)
Definition: AutoLoader.php:33
static registerDirectory($dirName)
Store the filename (sans extension) & full path of all ".php" files found.
Definition: AutoLoader.php:9
static $classNames
Definition: AutoLoader.php:4
static registerClass($className, $fileName)
Definition: AutoLoader.php:29
if(empty($site_name)) elseif($piwik->site_add( $site_name, $site_urls))