1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace Nette\Loaders;
13:
14: use Nette;
15:
16:
17:
18: 19: 20: 21: 22:
23: class NetteLoader extends AutoLoader
24: {
25:
26: private static $instance;
27:
28:
29: public $list = array(
30: 'ArgumentOutOfRangeException' => '/Utils/exceptions',
31: 'DeprecatedException' => '/Utils/exceptions',
32: 'DirectoryNotFoundException' => '/Utils/exceptions',
33: 'FatalErrorException' => '/Utils/exceptions',
34: 'FileNotFoundException' => '/Utils/exceptions',
35: 'IOException' => '/Utils/exceptions',
36: 'InvalidStateException' => '/Utils/exceptions',
37: 'MemberAccessException' => '/Utils/exceptions',
38: 'Nette\AmbiguousServiceException' => '/Environment/ServiceLocator',
39: 'Nette\Annotations' => '/Reflection/Annotations',
40: 'Nette\Application\AbortException' => '/Application/Exceptions/AbortException',
41: 'Nette\Application\ApplicationException' => '/Application/Exceptions/ApplicationException',
42: 'Nette\Application\BadRequestException' => '/Application/Exceptions/BadRequestException',
43: 'Nette\Application\BadSignalException' => '/Application/Exceptions/BadSignalException',
44: 'Nette\Application\CliRouter' => '/Application/Routers/CliRouter',
45: 'Nette\Application\DownloadResponse' => '/Application/Responses/DownloadResponse',
46: 'Nette\Application\ForbiddenRequestException' => '/Application/Exceptions/ForbiddenRequestException',
47: 'Nette\Application\ForwardingResponse' => '/Application/Responses/ForwardingResponse',
48: 'Nette\Application\IPartiallyRenderable' => '/Application/IRenderable',
49: 'Nette\Application\InvalidLinkException' => '/Application/Exceptions/InvalidLinkException',
50: 'Nette\Application\InvalidPresenterException' => '/Application/Exceptions/InvalidPresenterException',
51: 'Nette\Application\JsonResponse' => '/Application/Responses/JsonResponse',
52: 'Nette\Application\MultiRouter' => '/Application/Routers/MultiRouter',
53: 'Nette\Application\RedirectingResponse' => '/Application/Responses/RedirectingResponse',
54: 'Nette\Application\RenderResponse' => '/Application/Responses/RenderResponse',
55: 'Nette\Application\Route' => '/Application/Routers/Route',
56: 'Nette\Application\SimpleRouter' => '/Application/Routers/SimpleRouter',
57: 'Nette\ArrayTools' => '/Utils/ArrayTools',
58: 'Nette\Callback' => '/Utils/Callback',
59: 'Nette\Collections\KeyNotFoundException' => '/Collections/Hashtable',
60: 'Nette\Component' => '/ComponentModel/Component',
61: 'Nette\ComponentContainer' => '/ComponentModel/ComponentContainer',
62: 'Nette\Configurator' => '/Environment/Configurator',
63: 'Nette\DateTime' => '/Utils/DateTime',
64: 'Nette\Debug' => '/Debug/Debug',
65: 'Nette\Environment' => '/Environment/Environment',
66: 'Nette\Forms\Button' => '/Forms/Controls/Button',
67: 'Nette\Forms\Checkbox' => '/Forms/Controls/Checkbox',
68: 'Nette\Forms\ConventionalRenderer' => '/Forms/Renderers/ConventionalRenderer',
69: 'Nette\Forms\FileUpload' => '/Forms/Controls/FileUpload',
70: 'Nette\Forms\FormControl' => '/Forms/Controls/FormControl',
71: 'Nette\Forms\HiddenField' => '/Forms/Controls/HiddenField',
72: 'Nette\Forms\ImageButton' => '/Forms/Controls/ImageButton',
73: 'Nette\Forms\InstantClientScript' => '/Forms/Renderers/InstantClientScript',
74: 'Nette\Forms\MultiSelectBox' => '/Forms/Controls/MultiSelectBox',
75: 'Nette\Forms\RadioList' => '/Forms/Controls/RadioList',
76: 'Nette\Forms\SelectBox' => '/Forms/Controls/SelectBox',
77: 'Nette\Forms\SubmitButton' => '/Forms/Controls/SubmitButton',
78: 'Nette\Forms\TextArea' => '/Forms/Controls/TextArea',
79: 'Nette\Forms\TextBase' => '/Forms/Controls/TextBase',
80: 'Nette\Forms\TextInput' => '/Forms/Controls/TextInput',
81: 'Nette\Framework' => '/Utils/Framework',
82: 'Nette\FreezableObject' => '/Utils/FreezableObject',
83: 'Nette\GenericRecursiveIterator' => '/Utils/Iterators/GenericRecursiveIterator',
84: 'Nette\IComponent' => '/ComponentModel/IComponent',
85: 'Nette\IComponentContainer' => '/ComponentModel/IComponentContainer',
86: 'Nette\IDebuggable' => '/Debug/IDebuggable',
87: 'Nette\IO\SafeStream' => '/Utils/SafeStream',
88: 'Nette\IServiceLocator' => '/Environment/IServiceLocator',
89: 'Nette\ITranslator' => '/Utils/ITranslator',
90: 'Nette\Image' => '/Utils/Image',
91: 'Nette\ImageMagick' => '/Utils/ImageMagick',
92: 'Nette\InstanceFilterIterator' => '/Utils/Iterators/InstanceFilterIterator',
93: 'Nette\Object' => '/Utils/Object',
94: 'Nette\ObjectMixin' => '/Utils/ObjectMixin',
95: 'Nette\Paginator' => '/Utils/Paginator',
96: 'Nette\RecursiveComponentIterator' => '/ComponentModel/ComponentContainer',
97: 'Nette\ServiceLocator' => '/Environment/ServiceLocator',
98: 'Nette\SmartCachingIterator' => '/Utils/Iterators/SmartCachingIterator',
99: 'Nette\String' => '/Utils/String',
100: 'Nette\Templates\CachingHelper' => '/Templates/Filters/CachingHelper',
101: 'Nette\Templates\CurlyBracketsFilter' => '/Templates/Filters/LatteFilter',
102: 'Nette\Templates\CurlyBracketsMacros' => '/Templates/Filters/LatteFilter',
103: 'Nette\Templates\LatteFilter' => '/Templates/Filters/LatteFilter',
104: 'Nette\Templates\LatteMacros' => '/Templates/Filters/LatteMacros',
105: 'Nette\Templates\SnippetHelper' => '/Templates/Filters/SnippetHelper',
106: 'Nette\Templates\TemplateFilters' => '/Templates/Filters/TemplateFilters',
107: 'Nette\Templates\TemplateHelpers' => '/Templates/Filters/TemplateHelpers',
108: 'Nette\Tools' => '/Utils/Tools',
109: 'Nette\Web\FtpException' => '/Web/Ftp',
110: 'NotImplementedException' => '/Utils/exceptions',
111: 'NotSupportedException' => '/Utils/exceptions',
112: );
113:
114:
115:
116: 117: 118: 119:
120: public static function getInstance()
121: {
122: if (self::$instance === NULL) {
123: self::$instance = new self;
124: }
125: return self::$instance;
126: }
127:
128:
129:
130: 131: 132: 133: 134:
135: public function tryLoad($type)
136: {
137: $type = ltrim($type, '\\');
138: if (isset($this->list[$type])) {
139: LimitedScope::load(NETTE_DIR . $this->list[$type] . '.php', TRUE);
140: self::$count++;
141:
142: } elseif (substr($type, 0, 6) === 'Nette\\' && is_file($file = NETTE_DIR . strtr(substr($type, 5), '\\', '/') . '.php')) {
143: LimitedScope::load($file, TRUE);
144: self::$count++;
145: }
146: }
147:
148: }
149: