Source for file NetteLoader.php

Documentation is available at NetteLoader.php

  1. 1: <?php
  2. 2:  
  3. 3: /**
  4. 4:  * Nette Framework
  5. 5:  *
  6. 6:  * @copyright  Copyright (c) 2004, 2010 David Grudl
  7. 7:  * @license    http://nettephp.com/license  Nette license
  8. 8:  * @link       http://nettephp.com
  9. 9:  * @category   Nette
  10. 10:  * @package    Nette\Loaders
  11. 11:  */
  12. 12:  
  13. 13:  
  14. 14:  
  15. 15: /**
  16. 16:  * Nette auto loader is responsible for loading Nette classes and interfaces.
  17. 17:  *
  18. 18:  * @copyright  Copyright (c) 2004, 2010 David Grudl
  19. 19:  * @package    Nette\Loaders
  20. 20:  */
  21. 21: class NetteLoader extends AutoLoader
  22. 22: {
  23. 23:     /** @var NetteLoader */
  24. 24:     public static $instance;
  25. 25:  
  26. 26:     /** @var string  base file path */
  27. 27:     public $base;
  28. 28:  
  29. 29:     /** @var array */
  30. 30:     public $list = array(
  31. 31:         'abortexception' => '/Application/Exceptions/AbortException.php',
  32. 32:         'ambiguousserviceexception' => '/ServiceLocator.php',
  33. 33:         'annotation' => '/Reflection/Annotation.php',
  34. 34:         'annotations' => '/Annotations.php',
  35. 35:         'annotationsparser' => '/Reflection/AnnotationsParser.php',
  36. 36:         'appform' => '/Application/AppForm.php',
  37. 37:         'application' => '/Application/Application.php',
  38. 38:         'applicationexception' => '/Application/Exceptions/ApplicationException.php',
  39. 39:         'argumentoutofrangeexception' => '/exceptions.php',
  40. 40:         'arraylist' => '/Collections/ArrayList.php',
  41. 41:         'arraytools' => '/ArrayTools.php',
  42. 42:         'authenticationexception' => '/Security/AuthenticationException.php',
  43. 43:         'autoloader' => '/Loaders/AutoLoader.php',
  44. 44:         'badrequestexception' => '/Application/Exceptions/BadRequestException.php',
  45. 45:         'badsignalexception' => '/Application/Exceptions/BadSignalException.php',
  46. 46:         'basetemplate' => '/Templates/BaseTemplate.php',
  47. 47:         'button' => '/Forms/Controls/Button.php',
  48. 48:         'cache' => '/Caching/Cache.php',
  49. 49:         'cachinghelper' => '/Templates/Filters/CachingHelper.php',
  50. 50:         'callback' => '/Callback.php',
  51. 51:         'checkbox' => '/Forms/Controls/Checkbox.php',
  52. 52:         'classreflection' => '/Reflection/ClassReflection.php',
  53. 53:         'clirouter' => '/Application/Routers/CliRouter.php',
  54. 54:         'collection' => '/Collections/Collection.php',
  55. 55:         'component' => '/Component.php',
  56. 56:         'componentcontainer' => '/ComponentContainer.php',
  57. 57:         'config' => '/Config/Config.php',
  58. 58:         'configadapterini' => '/Config/ConfigAdapterIni.php',
  59. 59:         'configurator' => '/Configurator.php',
  60. 60:         'control' => '/Application/Control.php',
  61. 61:         'conventionalrenderer' => '/Forms/Renderers/ConventionalRenderer.php',
  62. 62:         'curlybracketsfilter' => '/Templates/Filters/LatteFilter.php',
  63. 63:         'curlybracketsmacros' => '/Templates/Filters/LatteFilter.php',
  64. 64:         'datetime53' => '/compatibility/DateTime53.php',
  65. 65:         'debug' => '/Debug.php',
  66. 66:         'deprecatedexception' => '/exceptions.php',
  67. 67:         'directorynotfoundexception' => '/exceptions.php',
  68. 68:         'downloadresponse' => '/Application/Responses/DownloadResponse.php',
  69. 69:         'dummystorage' => '/Caching/DummyStorage.php',
  70. 70:         'environment' => '/Environment.php',
  71. 71:         'extensionreflection' => '/Reflection/ExtensionReflection.php',
  72. 72:         'fatalerrorexception' => '/exceptions.php',
  73. 73:         'filenotfoundexception' => '/exceptions.php',
  74. 74:         'filestorage' => '/Caching/FileStorage.php',
  75. 75:         'fileupload' => '/Forms/Controls/FileUpload.php',
  76. 76:         'forbiddenrequestexception' => '/Application/Exceptions/ForbiddenRequestException.php',
  77. 77:         'form' => '/Forms/Form.php',
  78. 78:         'formcontainer' => '/Forms/FormContainer.php',
  79. 79:         'formcontrol' => '/Forms/Controls/FormControl.php',
  80. 80:         'formgroup' => '/Forms/FormGroup.php',
  81. 81:         'forwardingresponse' => '/Application/Responses/ForwardingResponse.php',
  82. 82:         'framework' => '/Framework.php',
  83. 83:         'freezableobject' => '/FreezableObject.php',
  84. 84:         'ftp' => '/Web/Ftp.php',
  85. 85:         'ftpexception' => '/Web/Ftp.php',
  86. 86:         'functionreflection' => '/Reflection/FunctionReflection.php',
  87. 87:         'hashtable' => '/Collections/Hashtable.php',
  88. 88:         'hiddenfield' => '/Forms/Controls/HiddenField.php',
  89. 89:         'html' => '/Web/Html.php',
  90. 90:         'httpcontext' => '/Web/HttpContext.php',
  91. 91:         'httprequest' => '/Web/HttpRequest.php',
  92. 92:         'httpresponse' => '/Web/HttpResponse.php',
  93. 93:         'httpuploadedfile' => '/Web/HttpUploadedFile.php',
  94. 94:         'iannotation' => '/Reflection/IAnnotation.php',
  95. 95:         'iauthenticator' => '/Security/IAuthenticator.php',
  96. 96:         'iauthorizator' => '/Security/IAuthorizator.php',
  97. 97:         'icachestorage' => '/Caching/ICacheStorage.php',
  98. 98:         'icollection' => '/Collections/ICollection.php',
  99. 99:         'icomponent' => '/IComponent.php',
  100. 100:         'icomponentcontainer' => '/IComponentContainer.php',
  101. 101:         'iconfigadapter' => '/Config/IConfigAdapter.php',
  102. 102:         'idebuggable' => '/IDebuggable.php',
  103. 103:         'identity' => '/Security/Identity.php',
  104. 104:         'ifiletemplate' => '/Templates/IFileTemplate.php',
  105. 105:         'iformcontrol' => '/Forms/IFormControl.php',
  106. 106:         'iformrenderer' => '/Forms/IFormRenderer.php',
  107. 107:         'ihttprequest' => '/Web/IHttpRequest.php',
  108. 108:         'ihttpresponse' => '/Web/IHttpResponse.php',
  109. 109:         'iidentity' => '/Security/IIdentity.php',
  110. 110:         'ilist' => '/Collections/IList.php',
  111. 111:         'image' => '/Image.php',
  112. 112:         'imagebutton' => '/Forms/Controls/ImageButton.php',
  113. 113:         'imagemagick' => '/ImageMagick.php',
  114. 114:         'imailer' => '/Mail/IMailer.php',
  115. 115:         'imap' => '/Collections/IMap.php',
  116. 116:         'inamingcontainer' => '/Forms/INamingContainer.php',
  117. 117:         'instancefilteriterator' => '/InstanceFilterIterator.php',
  118. 118:         'instantclientscript' => '/Forms/Renderers/InstantClientScript.php',
  119. 119:         'invalidlinkexception' => '/Application/Exceptions/InvalidLinkException.php',
  120. 120:         'invalidpresenterexception' => '/Application/Exceptions/InvalidPresenterException.php',
  121. 121:         'invalidstateexception' => '/exceptions.php',
  122. 122:         'ioexception' => '/exceptions.php',
  123. 123:         'ipartiallyrenderable' => '/Application/IRenderable.php',
  124. 124:         'ipermissionassertion' => '/Security/IPermissionAssertion.php',
  125. 125:         'ipresenter' => '/Application/IPresenter.php',
  126. 126:         'ipresenterloader' => '/Application/IPresenterLoader.php',
  127. 127:         'ipresenterresponse' => '/Application/IPresenterResponse.php',
  128. 128:         'irenderable' => '/Application/IRenderable.php',
  129. 129:         'iresource' => '/Security/IResource.php',
  130. 130:         'irole' => '/Security/IRole.php',
  131. 131:         'irouter' => '/Application/IRouter.php',
  132. 132:         'iservicelocator' => '/IServiceLocator.php',
  133. 133:         'iset' => '/Collections/ISet.php',
  134. 134:         'isignalreceiver' => '/Application/ISignalReceiver.php',
  135. 135:         'istatepersistent' => '/Application/IStatePersistent.php',
  136. 136:         'isubmittercontrol' => '/Forms/ISubmitterControl.php',
  137. 137:         'itemplate' => '/Templates/ITemplate.php',
  138. 138:         'itranslator' => '/ITranslator.php',
  139. 139:         'iuser' => '/Web/IUser.php',
  140. 140:         'jsonresponse' => '/Application/Responses/JsonResponse.php',
  141. 141:         'keynotfoundexception' => '/Collections/Hashtable.php',
  142. 142:         'lattefilter' => '/Templates/Filters/LatteFilter.php',
  143. 143:         'lattemacros' => '/Templates/Filters/LatteMacros.php',
  144. 144:         'limitedscope' => '/Loaders/LimitedScope.php',
  145. 145:         'link' => '/Application/Link.php',
  146. 146:         'mail' => '/Mail/Mail.php',
  147. 147:         'mailmimepart' => '/Mail/MailMimePart.php',
  148. 148:         'memberaccessexception' => '/exceptions.php',
  149. 149:         'memcachedstorage' => '/Caching/MemcachedStorage.php',
  150. 150:         'methodparameterreflection' => '/Reflection/MethodParameterReflection.php',
  151. 151:         'methodreflection' => '/Reflection/MethodReflection.php',
  152. 152:         'multirouter' => '/Application/Routers/MultiRouter.php',
  153. 153:         'multiselectbox' => '/Forms/Controls/MultiSelectBox.php',
  154. 154:         'netteloader' => '/Loaders/NetteLoader.php',
  155. 155:         'notimplementedexception' => '/exceptions.php',
  156. 156:         'notsupportedexception' => '/exceptions.php',
  157. 157:         'object' => '/Object.php',
  158. 158:         'objectmixin' => '/ObjectMixin.php',
  159. 159:         'paginator' => '/Paginator.php',
  160. 160:         'permission' => '/Security/Permission.php',
  161. 161:         'presenter' => '/Application/Presenter.php',
  162. 162:         'presentercomponent' => '/Application/PresenterComponent.php',
  163. 163:         'presentercomponentreflection' => '/Application/PresenterComponentReflection.php',
  164. 164:         'presenterloader' => '/Application/PresenterLoader.php',
  165. 165:         'presenterrequest' => '/Application/PresenterRequest.php',
  166. 166:         'propertyreflection' => '/Reflection/PropertyReflection.php',
  167. 167:         'radiolist' => '/Forms/Controls/RadioList.php',
  168. 168:         'recursivecomponentiterator' => '/ComponentContainer.php',
  169. 169:         'recursivehtmliterator' => '/Web/Html.php',
  170. 170:         'redirectingresponse' => '/Application/Responses/RedirectingResponse.php',
  171. 171:         'renderresponse' => '/Application/Responses/RenderResponse.php',
  172. 172:         'robotloader' => '/Loaders/RobotLoader.php',
  173. 173:         'route' => '/Application/Routers/Route.php',
  174. 174:         'rule' => '/Forms/Rule.php',
  175. 175:         'rules' => '/Forms/Rules.php',
  176. 176:         'safestream' => '/IO/SafeStream.php',
  177. 177:         'selectbox' => '/Forms/Controls/SelectBox.php',
  178. 178:         'sendmailmailer' => '/Mail/SendmailMailer.php',
  179. 179:         'servicelocator' => '/ServiceLocator.php',
  180. 180:         'session' => '/Web/Session.php',
  181. 181:         'sessionnamespace' => '/Web/SessionNamespace.php',
  182. 182:         'set' => '/Collections/Set.php',
  183. 183:         'simpleauthenticator' => '/Security/SimpleAuthenticator.php',
  184. 184:         'simplerouter' => '/Application/Routers/SimpleRouter.php',
  185. 185:         'smartcachingiterator' => '/SmartCachingIterator.php',
  186. 186:         'snippethelper' => '/Templates/Filters/SnippetHelper.php',
  187. 187:         'string' => '/String.php',
  188. 188:         'submitbutton' => '/Forms/Controls/SubmitButton.php',
  189. 189:         'template' => '/Templates/Template.php',
  190. 190:         'templatecachestorage' => '/Templates/TemplateCacheStorage.php',
  191. 191:         'templatefilters' => '/Templates/Filters/TemplateFilters.php',
  192. 192:         'templatehelpers' => '/Templates/Filters/TemplateHelpers.php',
  193. 193:         'textarea' => '/Forms/Controls/TextArea.php',
  194. 194:         'textbase' => '/Forms/Controls/TextBase.php',
  195. 195:         'textinput' => '/Forms/Controls/TextInput.php',
  196. 196:         'tools' => '/Tools.php',
  197. 197:         'uri' => '/Web/Uri.php',
  198. 198:         'uriscript' => '/Web/UriScript.php',
  199. 199:         'user' => '/Web/User.php',
  200. 200:     );
  201. 201:  
  202. 202:  
  203. 203:  
  204. 204:     /**
  205. 205:      * Returns singleton instance with lazy instantiation.
  206. 206:      * @return NetteLoader 
  207. 207:      */
  208. 208:     public static function getInstance()
  209. 209:     {
  210. 210:         if (self::$instance === NULL{
  211. 211:             self::$instance new self;
  212. 212:         }
  213. 213:         return self::$instance;
  214. 214:     }
  215. 215:  
  216. 216:  
  217. 217:  
  218. 218:     /**
  219. 219:      * Handles autoloading of classes or interfaces.
  220. 220:      * @param  string 
  221. 221:      * @return void 
  222. 222:      */
  223. 223:     public function tryLoad($type)
  224. 224:     {
  225. 225:         $type strtolower($type);
  226. 226:         if (isset($this->list[$type])) {
  227. 227:             LimitedScope::load($this->base . $this->list[$type]);
  228. 228:             self::$count++;
  229. 229:         }
  230. 230:     }
  231. 231: