Namespaces

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

Classes

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