Namespaces

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Diagnostics
      • Extensions
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
      • Diagnostics
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • PhpGenerator
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
  • NetteModule
  • none

Classes

  • AutoLoader
  • NetteLoader
  • RobotLoader
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage
  1: <?php
  2: 
  3: /**
  4:  * This file is part of the Nette Framework (https://nette.org)
  5:  * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
  6:  */
  7: 
  8: namespace Nette\Loaders;
  9: 
 10: use Nette;
 11: 
 12: 
 13: /**
 14:  * Nette auto loader is responsible for loading Nette classes and interfaces.
 15:  *
 16:  * @author     David Grudl
 17:  */
 18: class NetteLoader extends Nette\Object
 19: {
 20:     /** @var NetteLoader */
 21:     private static $instance;
 22: 
 23:     /** @var array */
 24:     public $renamed = array(
 25:         'Nette\Config\Configurator' => 'Nette\Configurator',
 26:         'Nette\Config\CompilerExtension' => 'Nette\DI\CompilerExtension',
 27:         'Nette\Http\User' => 'Nette\Security\User',
 28:         'Nette\Templating\DefaultHelpers' => 'Nette\Templating\Helpers',
 29:         'Nette\Latte\ParseException' => 'Nette\Latte\CompileException',
 30:         'Nette\Utils\PhpGenerator\ClassType' => 'Nette\PhpGenerator\ClassType',
 31:         'Nette\Utils\PhpGenerator\Helpers' => 'Nette\PhpGenerator\Helpers',
 32:         'Nette\Utils\PhpGenerator\Method' => 'Nette\PhpGenerator\Method',
 33:         'Nette\Utils\PhpGenerator\Parameter' => 'Nette\PhpGenerator\Parameter',
 34:         'Nette\Utils\PhpGenerator\PhpLiteral' => 'Nette\PhpGenerator\PhpLiteral',
 35:         'Nette\Utils\PhpGenerator\Property' => 'Nette\PhpGenerator\Property',
 36:     );
 37: 
 38:     /** @var array */
 39:     public $list = array(
 40:         'NetteModule\ErrorPresenter' => 'Application/ErrorPresenter',
 41:         'NetteModule\MicroPresenter' => 'Application/MicroPresenter',
 42:         'Nette\Application\AbortException' => 'Application/exceptions',
 43:         'Nette\Application\ApplicationException' => 'Application/exceptions',
 44:         'Nette\Application\BadRequestException' => 'Application/exceptions',
 45:         'Nette\Application\ForbiddenRequestException' => 'Application/exceptions',
 46:         'Nette\Application\InvalidPresenterException' => 'Application/exceptions',
 47:         'Nette\ArgumentOutOfRangeException' => 'common/exceptions',
 48:         'Nette\ArrayHash' => 'common/ArrayHash',
 49:         'Nette\ArrayList' => 'common/ArrayList',
 50:         'Nette\Callback' => 'common/Callback',
 51:         'Nette\Configurator' => 'common/Configurator',
 52:         'Nette\DI\MissingServiceException' => 'DI/exceptions',
 53:         'Nette\DI\ServiceCreationException' => 'DI/exceptions',
 54:         'Nette\Database\Reflection\AmbiguousReferenceKeyException' => 'Database/Reflection/exceptions',
 55:         'Nette\Database\Reflection\MissingReferenceException' => 'Database/Reflection/exceptions',
 56:         'Nette\DateTime' => 'common/DateTime',
 57:         'Nette\DeprecatedException' => 'common/exceptions',
 58:         'Nette\DirectoryNotFoundException' => 'common/exceptions',
 59:         'Nette\Environment' => 'common/Environment',
 60:         'Nette\FatalErrorException' => 'common/exceptions',
 61:         'Nette\FileNotFoundException' => 'common/exceptions',
 62:         'Nette\Framework' => 'common/Framework',
 63:         'Nette\FreezableObject' => 'common/FreezableObject',
 64:         'Nette\IFreezable' => 'common/IFreezable',
 65:         'Nette\IOException' => 'common/exceptions',
 66:         'Nette\Image' => 'common/Image',
 67:         'Nette\InvalidArgumentException' => 'common/exceptions',
 68:         'Nette\InvalidStateException' => 'common/exceptions',
 69:         'Nette\Latte\CompileException' => 'Latte/exceptions',
 70:         'Nette\Mail\SmtpException' => 'Mail/SmtpMailer',
 71:         'Nette\MemberAccessException' => 'common/exceptions',
 72:         'Nette\NotImplementedException' => 'common/exceptions',
 73:         'Nette\NotSupportedException' => 'common/exceptions',
 74:         'Nette\Object' => 'common/Object',
 75:         'Nette\ObjectMixin' => 'common/ObjectMixin',
 76:         'Nette\OutOfRangeException' => 'common/exceptions',
 77:         'Nette\StaticClassException' => 'common/exceptions',
 78:         'Nette\UnexpectedValueException' => 'common/exceptions',
 79:         'Nette\UnknownImageFileException' => 'common/Image',
 80:         'Nette\Utils\AssertionException' => 'Utils/Validators',
 81:         'Nette\Utils\JsonException' => 'Utils/Json',
 82:         'Nette\Utils\NeonEntity' => 'Utils/Neon',
 83:         'Nette\Utils\NeonException' => 'Utils/Neon',
 84:         'Nette\Utils\RegexpException' => 'Utils/Strings',
 85:         'Nette\Utils\TokenizerException' => 'Utils/Tokenizer',
 86:     );
 87: 
 88: 
 89:     /**
 90:      * Returns singleton instance with lazy instantiation.
 91:      * @return NetteLoader
 92:      */
 93:     public static function getInstance()
 94:     {
 95:         if (self::$instance === NULL) {
 96:             self::$instance = new static;
 97:         }
 98:         return self::$instance;
 99:     }
100: 
101: 
102:     /**
103:      * Register autoloader.
104:      * @param  bool  prepend autoloader?
105:      * @return void
106:      */
107:     public function register($prepend = FALSE)
108:     {
109:         spl_autoload_register(array($this, 'tryLoad'), TRUE, (bool) $prepend);
110:     }
111: 
112: 
113:     /**
114:      * Handles autoloading of classes or interfaces.
115:      * @param  string
116:      * @return void
117:      */
118:     public function tryLoad($type)
119:     {
120:         $type = ltrim($type, '\\');
121:         if (isset($this->renamed[$type])) {
122:             class_alias($this->renamed[$type], $type);
123:             trigger_error("Class $type has been renamed to {$this->renamed[$type]}.", E_USER_WARNING);
124: 
125:         } elseif (isset($this->list[$type])) {
126:             require __DIR__ . '/../' . $this->list[$type] . '.php';
127: 
128:         } elseif (substr($type, 0, 6) === 'Nette\\' && is_file($file = __DIR__ . '/../' . strtr(substr($type, 5), '\\', '/') . '.php')) {
129:             require $file;
130:         }
131:     }
132: 
133: }
134: 
Nette 2.1 API documentation generated by ApiGen 2.8.0