gluon-web-remote

Web remote Administration for big size of gluon routers
git clone git://archive.git.mtrnord.blog/MTRNord/gluon-web-remote.git
Log | Files | Refs | README

commit 863af61dea45db1c1e8224a622f82384b17d7cfd
parent 44a3af995f02384a2dbc27682532d0ca35e6b545
Author: Marcel <MTRNord@users.noreply.github.com>
Date:   Tue, 13 Oct 2015 20:56:55 +0200

Create AutoLoader.php
Diffstat:
Atests/AutoLoader.php | 29+++++++++++++++++++++++++++++
1 file changed, 29 insertions(+), 0 deletions(-)

diff --git a/tests/AutoLoader.php b/tests/AutoLoader.php @@ -0,0 +1,29 @@ +<?php +class AutoLoader { + static private $classNames = array(); + /** + * 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 = substr($file->getFilename(), 0, -4); + AutoLoader::registerClass($className, $file->getPathname()); + } + } + } + public static function registerClass($className, $fileName) { + AutoLoader::$classNames[$className] = $fileName; + } + public static function loadClass($className) { + if (isset(AutoLoader::$classNames[$className])) { + require_once(AutoLoader::$classNames[$className]); + } + } + } + spl_autoload_register(array('AutoLoader', 'loadClass'));