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 (c) 2004, 2009 David Grudl (http://davidgrudl.com)
  7. 7:  *
  8. 8:  * This source file is subject to the "Nette license" that is bundled
  9. 9:  * with this package in the file license.txt.
  10. 10:  *
  11. 11:  * For more information please see http://nettephp.com
  12. 12:  *
  13. 13:  * @copyright  Copyright (c) 2004, 2009 David Grudl
  14. 14:  * @license    http://nettephp.com/license  Nette license
  15. 15:  * @link       http://nettephp.com
  16. 16:  * @category   Nette
  17. 17:  * @package    Loaders
  18. 18:  */
  19. 19:  
  20. 20:  
  21. 21:  
  22. 22: require_once dirname(__FILE__'/../Loaders/AutoLoader.php';
  23. 23:  
  24. 24:  
  25. 25:  
  26. 26: /**
  27. 27:  * Nette auto loader is responsible for loading Nette classes and interfaces.
  28. 28:  *
  29. 29:  * @author     David Grudl
  30. 30:  * @copyright  Copyright (c) 2004, 2009 David Grudl
  31. 31:  * @package    Loaders
  32. 32:  */
  33. 33: class NNetteLoader extends NAutoLoader
  34. 34: {
  35. 35:     /** @var NNetteLoader */
  36. 36:     public static $instance;
  37. 37:  
  38. 38:     /** @var string  base file path */
  39. 39:     public $base;
  40. 40:  
  41. 41:     /** @var array */
  42. 42:     public $list = array(
  43. 43:         'argumentoutofrangeexception' => '/exceptions.php',
  44. 44:         'deprecatedexception' => '/exceptions.php',
  45. 45:         'directorynotfoundexception' => '/exceptions.php',
  46. 46:         'fatalerrorexception' => '/exceptions.php',
  47. 47:         'filenotfoundexception' => '/exceptions.php',
  48. 48:         'iauthenticator' => '/Security/IAuthenticator.php',
  49. 49:         'iauthorizator' => '/Security/IAuthorizator.php',
  50. 50:         'icachestorage' => '/Caching/ICacheStorage.php',
  51. 51:         'icollection' => '/Collections/ICollection.php',
  52. 52:         'icomponent' => '/IComponent.php',
  53. 53:         'icomponentcontainer' => '/IComponentContainer.php',
  54. 54:         'iconfigadapter' => '/Config/IConfigAdapter.php',
  55. 55:         'idebuggable' => '/IDebuggable.php',
  56. 56:         'ifiletemplate' => '/Templates/IFileTemplate.php',
  57. 57:         'iformcontrol' => '/Forms/IFormControl.php',
  58. 58:         'iformrenderer' => '/Forms/IFormRenderer.php',
  59. 59:         'ihttprequest' => '/Web/IHttpRequest.php',
  60. 60:         'ihttpresponse' => '/Web/IHttpResponse.php',
  61. 61:         'iidentity' => '/Security/IIdentity.php',
  62. 62:         'ilist' => '/Collections/IList.php',
  63. 63:         'imailer' => '/Mail/IMailer.php',
  64. 64:         'imap' => '/Collections/IMap.php',
  65. 65:         'inamingcontainer' => '/Forms/INamingContainer.php',
  66. 66:         'invalidstateexception' => '/exceptions.php',
  67. 67:         'ioexception' => '/exceptions.php',
  68. 68:         'ipartiallyrenderable' => '/Application/IRenderable.php',
  69. 69:         'ipermissionassertion' => '/Security/IPermissionAssertion.php',
  70. 70:         'ipresenter' => '/Application/IPresenter.php',
  71. 71:         'ipresenterloader' => '/Application/IPresenterLoader.php',
  72. 72:         'ipresenterresponse' => '/Application/IPresenterResponse.php',
  73. 73:         'irenderable' => '/Application/IRenderable.php',
  74. 74:         'iresource' => '/Security/IResource.php',
  75. 75:         'irole' => '/Security/IRole.php',
  76. 76:         'irouter' => '/Application/IRouter.php',
  77. 77:         'iservicelocator' => '/IServiceLocator.php',
  78. 78:         'iset' => '/Collections/ISet.php',
  79. 79:         'isignalreceiver' => '/Application/ISignalReceiver.php',
  80. 80:         'istatepersistent' => '/Application/IStatePersistent.php',
  81. 81:         'isubmittercontrol' => '/Forms/ISubmitterControl.php',
  82. 82:         'itemplate' => '/Templates/ITemplate.php',
  83. 83:         'itranslator' => '/ITranslator.php',
  84. 84:         'iuser' => '/Web/IUser.php',
  85. 85:         'lattefilter' => '/Templates/Filters/LatteFilter.php',
  86. 86:         'lattemacros' => '/Templates/Filters/LatteMacros.php',
  87. 87:         'memberaccessexception' => '/exceptions.php',
  88. 88:         'nabortexception' => '/Application/Exceptions/AbortException.php',
  89. 89:         'nambiguousserviceexception' => '/ServiceLocator.php',
  90. 90:         'nannotations' => '/Annotations.php',
  91. 91:         'nappform' => '/Application/AppForm.php',
  92. 92:         'napplication' => '/Application/Application.php',
  93. 93:         'napplicationexception' => '/Application/Exceptions/ApplicationException.php',
  94. 94:         'narraylist' => '/Collections/ArrayList.php',
  95. 95:         'narraytools' => '/ArrayTools.php',
  96. 96:         'nauthenticationexception' => '/Security/AuthenticationException.php',
  97. 97:         'nautoloader' => '/Loaders/AutoLoader.php',
  98. 98:         'nbadrequestexception' => '/Application/Exceptions/BadRequestException.php',
  99. 99:         'nbadsignalexception' => '/Application/Exceptions/BadSignalException.php',
  100. 100:         'nbasetemplate' => '/Templates/BaseTemplate.php',
  101. 101:         'nbutton' => '/Forms/Controls/Button.php',
  102. 102:         'ncache' => '/Caching/Cache.php',
  103. 103:         'ncachinghelper' => '/Templates/Filters/CachingHelper.php',
  104. 104:         'ncheckbox' => '/Forms/Controls/Checkbox.php',
  105. 105:         'nclirouter' => '/Application/Routers/CliRouter.php',
  106. 106:         'ncollection' => '/Collections/Collection.php',
  107. 107:         'ncomponent' => '/Component.php',
  108. 108:         'ncomponentcontainer' => '/ComponentContainer.php',
  109. 109:         'nconfig' => '/Config/Config.php',
  110. 110:         'nconfigadapterini' => '/Config/ConfigAdapterIni.php',
  111. 111:         'nconfigadapterxml' => '/Config/ConfigAdapterXml.php',
  112. 112:         'nconfigurator' => '/Configurator.php',
  113. 113:         'ncontrol' => '/Application/Control.php',
  114. 114:         'nconventionalrenderer' => '/Forms/Renderers/ConventionalRenderer.php',
  115. 115:         'ncurlybracketsfilter' => '/Templates/Filters/LatteFilter.php',
  116. 116:         'ncurlybracketsmacros' => '/Templates/Filters/LatteFilter.php',
  117. 117:         'ndebug' => '/Debug.php',
  118. 118:         'ndownloadresponse' => '/Application/Responses/DownloadResponse.php',
  119. 119:         'ndummystorage' => '/Caching/DummyStorage.php',
  120. 120:         'nenvironment' => '/Environment.php',
  121. 121:         'nfilestorage' => '/Caching/FileStorage.php',
  122. 122:         'nfileupload' => '/Forms/Controls/FileUpload.php',
  123. 123:         'nform' => '/Forms/Form.php',
  124. 124:         'nformcontainer' => '/Forms/FormContainer.php',
  125. 125:         'nformcontrol' => '/Forms/Controls/FormControl.php',
  126. 126:         'nformgroup' => '/Forms/FormGroup.php',
  127. 127:         'nforwardingresponse' => '/Application/Responses/ForwardingResponse.php',
  128. 128:         'nframework' => '/Framework.php',
  129. 129:         'nfreezableobject' => '/FreezableObject.php',
  130. 130:         'nftp' => '/Web/Ftp.php',
  131. 131:         'nftpexception' => '/Web/Ftp.php',
  132. 132:         'nhashtable' => '/Collections/Hashtable.php',
  133. 133:         'nhiddenfield' => '/Forms/Controls/HiddenField.php',
  134. 134:         'nhtml' => '/Web/Html.php',
  135. 135:         'nhttprequest' => '/Web/HttpRequest.php',
  136. 136:         'nhttpresponse' => '/Web/HttpResponse.php',
  137. 137:         'nhttpuploadedfile' => '/Web/HttpUploadedFile.php',
  138. 138:         'nidentity' => '/Security/Identity.php',
  139. 139:         'nimage' => '/Image.php',
  140. 140:         'nimagebutton' => '/Forms/Controls/ImageButton.php',
  141. 141:         'nimagemagick' => '/ImageMagick.php',
  142. 142:         'ninstancefilteriterator' => '/InstanceFilterIterator.php',
  143. 143:         'ninstantclientscript' => '/Forms/Renderers/InstantClientScript.php',
  144. 144:         'ninvalidlinkexception' => '/Application/Exceptions/InvalidLinkException.php',
  145. 145:         'ninvalidpresenterexception' => '/Application/Exceptions/InvalidPresenterException.php',
  146. 146:         'njsonresponse' => '/Application/Responses/JsonResponse.php',
  147. 147:         'nkeynotfoundexception' => '/Collections/Hashtable.php',
  148. 148:         'nlimitedscope' => '/Loaders/LimitedScope.php',
  149. 149:         'nlink' => '/Application/Link.php',
  150. 150:         'nmail' => '/Mail/Mail.php',
  151. 151:         'nmailmimepart' => '/Mail/MailMimePart.php',
  152. 152:         'nmemcachedstorage' => '/Caching/MemcachedStorage.php',
  153. 153:         'nmultirouter' => '/Application/Routers/MultiRouter.php',
  154. 154:         'nmultiselectbox' => '/Forms/Controls/MultiSelectBox.php',
  155. 155:         'nnetteloader' => '/Loaders/NetteLoader.php',
  156. 156:         'nobject' => '/Object.php',
  157. 157:         'nobjectmixin' => '/ObjectMixin.php',
  158. 158:         'notimplementedexception' => '/exceptions.php',
  159. 159:         'notsupportedexception' => '/exceptions.php',
  160. 160:         'npaginator' => '/Paginator.php',
  161. 161:         'npermission' => '/Security/Permission.php',
  162. 162:         'npresenter' => '/Application/Presenter.php',
  163. 163:         'npresentercomponent' => '/Application/PresenterComponent.php',
  164. 164:         'npresenterhelpers' => '/Application/PresenterHelpers.php',
  165. 165:         'npresenterloader' => '/Application/PresenterLoader.php',
  166. 166:         'npresenterrequest' => '/Application/PresenterRequest.php',
  167. 167:         'nradiolist' => '/Forms/Controls/RadioList.php',
  168. 168:         'nrecursivecomponentiterator' => '/ComponentContainer.php',
  169. 169:         'nrecursivehtmliterator' => '/Web/Html.php',
  170. 170:         'nredirectingresponse' => '/Application/Responses/RedirectingResponse.php',
  171. 171:         'nrenderresponse' => '/Application/Responses/RenderResponse.php',
  172. 172:         'nrepeatercontrol' => '/Forms/Controls/RepeaterControl.php',
  173. 173:         'nrobotloader' => '/Loaders/RobotLoader.php',
  174. 174:         'nroute' => '/Application/Routers/Route.php',
  175. 175:         'nrule' => '/Forms/Rule.php',
  176. 176:         'nrules' => '/Forms/Rules.php',
  177. 177:         'nsafestream' => '/IO/SafeStream.php',
  178. 178:         'nselectbox' => '/Forms/Controls/SelectBox.php',
  179. 179:         'nsendmailmailer' => '/Mail/SendmailMailer.php',
  180. 180:         'nservicelocator' => '/ServiceLocator.php',
  181. 181:         'nsession' => '/Web/Session.php',
  182. 182:         'nsessionnamespace' => '/Web/SessionNamespace.php',
  183. 183:         'nset' => '/Collections/Set.php',
  184. 184:         'nsimpleauthenticator' => '/Security/SimpleAuthenticator.php',
  185. 185:         'nsimpleloader' => '/Loaders/SimpleLoader.php',
  186. 186:         'nsimplerouter' => '/Application/Routers/SimpleRouter.php',
  187. 187:         'nsmartcachingiterator' => '/SmartCachingIterator.php',
  188. 188:         'nsnippethelper' => '/Templates/Filters/SnippetHelper.php',
  189. 189:         'nstring' => '/String.php',
  190. 190:         'nsubmitbutton' => '/Forms/Controls/SubmitButton.php',
  191. 191:         'ntemplate' => '/Templates/Template.php',
  192. 192:         'ntemplatecachestorage' => '/Templates/TemplateCacheStorage.php',
  193. 193:         'ntemplatefilters' => '/Templates/Filters/TemplateFilters.php',
  194. 194:         'ntemplatehelpers' => '/Templates/Filters/TemplateHelpers.php',
  195. 195:         'ntextarea' => '/Forms/Controls/TextArea.php',
  196. 196:         'ntextbase' => '/Forms/Controls/TextBase.php',
  197. 197:         'ntextinput' => '/Forms/Controls/TextInput.php',
  198. 198:         'ntools' => '/Tools.php',
  199. 199:         'nuri' => '/Web/Uri.php',
  200. 200:         'nuriscript' => '/Web/UriScript.php',
  201. 201:         'nuser' => '/Web/User.php',
  202. 202:         'nuserclientscript' => '/Forms/Renderers/UserClientScript.php',
  203. 203:     );
  204. 204:  
  205. 205:  
  206. 206:  
  207. 207:     /**
  208. 208:      * Returns singleton instance with lazy instantiation.
  209. 209:      * @return NNetteLoader 
  210. 210:      */
  211. 211:     public static function getInstance()
  212. 212:     {
  213. 213:         if (self::$instance === NULL{
  214. 214:             self::$instance new self;
  215. 215:         }
  216. 216:         return self::$instance;
  217. 217:     }
  218. 218:  
  219. 219:  
  220. 220:  
  221. 221:     /**
  222. 222:      * Handles autoloading of classes or interfaces.
  223. 223:      * @param  string 
  224. 224:      * @return void 
  225. 225:      */
  226. 226:     public function tryLoad($type)
  227. 227:     {
  228. 228:         $type strtolower($type);
  229. 229:         if (isset($this->list[$type])) {
  230. 230:             NLimitedScope::load($this->base . $this->list[$type]);
  231. 231:             self::$count++;
  232. 232:         }
  233. 233:     }
  234. 234: