Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Jednoduchá třída pro autoloading.
- * Předpokládá, že všechny třídy (kromě Nette) jsou ve stejnojmenných souborech
- * v jediném adresáři, a *prefixovanou* verzi Nette.
- * (Mapa tříd/souborů pro Nette je převzatá z Nette\Loaders\AutoLoader.)
- *
- * @link http://sk2.php.net/manual/en/function.spl-autoload.php#103548 (Inspirace)
- * @link http://api.nette.org/2.0/Nette.Loaders.NetteLoader.html (API: Nette\AutoLoader)
- * @version 1.0
- * @since 2011-06-20
- *
- * Tento popis byl pro Nette 0.9, funkčnost pro verzi 2.0 jsem neověřovala.
- */
- class Loader {
- /** @var string Cesta k hlavnímu adresáři tříd. */
- static private $path;
- /** @var array Součásti Nette. */
- static private $nette = array(
- 'argumentoutofrangeexception' => '/common/exceptions.php',
- 'deprecatedexception' => '/common/exceptions.php',
- 'directorynotfoundexception' => '/common/exceptions.php',
- 'fatalerrorexception' => '/common/exceptions.php',
- 'filenotfoundexception' => '/common/exceptions.php',
- 'icachestorage' => '/Caching/IStorage.php',
- 'ifiletemplate' => '/Templating/IFileTemplate.php',
- 'imacro' => '/Latte/IMacro.php',
- 'invalidstateexception' => '/common/exceptions.php',
- 'ioexception' => '/common/exceptions.php',
- 'itemplate' => '/Templating/ITemplate.php',
- 'memberaccessexception' => '/common/exceptions.php',
- 'ncache' => '/Caching/Cache.php',
- 'ncachemacro' => '/Latte/Macros/CacheMacro.php',
- 'ncallback' => '/common/Callback.php',
- 'nclosurefix' => '/common/Framework.php',
- 'ncoremacros' => '/Latte/Macros/CoreMacros.php',
- 'ndebugger' => '/Diagnostics/Debugger.php',
- 'nfilestorage' => '/Caching/Storages/FileStorage.php',
- 'nfiletemplate' => '/Templating/FileTemplate.php',
- 'nformmacros' => '/Latte/Macros/FormMacros.php',
- 'nframework' => '/common/Framework.php',
- 'nhtml' => '/Utils/Html.php',
- 'nhtmlnode' => '/Latte/HtmlNode.php',
- 'nlatteexception' => '/Latte/ParseException.php',
- 'nlattefilter' => '/Latte/Engine.php',
- 'nlimitedscope' => '/Utils/LimitedScope.php',
- 'nmacronode' => '/Latte/MacroNode.php',
- 'nmacroset' => '/Latte/Macros/MacroSet.php',
- 'nmacrotokenizer' => '/Latte/MacroTokenizer.php',
- 'nobjectmixin' => '/common/ObjectMixin.php',
- 'notimplementedexception' => '/common/exceptions.php',
- 'notsupportedexception' => '/common/exceptions.php',
- 'nparser' => '/Latte/Parser.php',
- 'nregexpexception' => '/Utils/Strings.php',
- 'nsafestream' => '/Utils/SafeStream.php',
- 'nsmartcachingiterator' => '/Iterators/CachingIterator.php',
- 'nstaticclassexception' => '/common/exceptions.php',
- 'nstrings' => '/Utils/Strings.php',
- 'ntemplate' => '/Templating/Template.php',
- 'ntemplateexception' => '/Templating/FilterException.php',
- 'ntemplatehelpers' => '/Templating/DefaultHelpers.php',
- 'ntokenizer' => '/Utils/Tokenizer.php',
- 'ntokenizerexception' => '/Utils/Tokenizer.php',
- 'nuimacros' => '/Latte/Macros/UIMacros.php',
- );
- public static function registerAutoload($path) {
- self::$path = $path;
- return spl_autoload_register(array(__CLASS__, 'includeClass'));
- }
- public static function unregisterAutoload() {
- return spl_autoload_unregister(array(__CLASS__, 'includeClass'));
- }
- public static function includeClass($class) {
- if (isset(self::$nette[strtolower($class)]))
- require_once(self::$path . '/NetteTpl' . strtr(self::$nette[strtolower($class)], '_\\', '//'));
- else
- require_once(self::$path . '/' . strtr($class, '_\\', '//') . '.php');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement