-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed Loader class from core package and moved it to the root of the library. Updated examples with the new loader.
- Loading branch information
Mattijs Hoitink
committed
Oct 31, 2010
1 parent
19fdd66
commit 220870b
Showing
4 changed files
with
53 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* Loader.php | ||
* | ||
* @package Steel | ||
* @copyright Copyright (c) 2010 Mattijs Hoitink <mattijs@monkeyandmachine.com> | ||
* @license New BSD License - http://github.com/mattijs/Steel/raw/master/LICENSE | ||
*/ | ||
|
||
namespace steel\core; | ||
|
||
/** | ||
* Loader for Steel classes. | ||
* | ||
* @todo add class cache | ||
* @package Steel | ||
* @author Mattijs Hoitink <mattijs@monkeyandmachine.com> | ||
*/ | ||
class Loader | ||
{ | ||
|
||
/** | ||
* Autoloader implementation based on the example from | ||
* the PHP standards group. | ||
* @see http://groups.google.com/group/php-standards/web/psr-0-final-proposal | ||
* @param string $className | ||
*/ | ||
public static function autoload($className) | ||
{ | ||
$className = ltrim($className, '\\'); | ||
$fileName = ''; | ||
$namespace = ''; | ||
if ($lastNsPos = strripos($className, '\\')) { | ||
$namespace = substr($className, 0, $lastNsPos); | ||
$className = substr($className, $lastNsPos + 1); | ||
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; | ||
} | ||
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; | ||
|
||
require $fileName; | ||
} | ||
|
||
/** | ||
* Register this class with the autoloading stack. | ||
*/ | ||
public static function registerAutoload() | ||
{ | ||
spl_autoload_register(array('self', 'autoload')); | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.