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    Nette\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    Nette\Loaders
  32. 32:  */
  33. 33: class NetteLoader extends AutoLoader
  34. 34: {
  35. 35:     /** @var NetteLoader */
  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:         'abortexception' => '/Application/Exceptions/AbortException.php',
  44. 44:         'ambiguousserviceexception' => '/ServiceLocator.php',
  45. 45:         'annotations' => '/Annotations.php',
  46. 46:         'appform' => '/Application/AppForm.php',
  47. 47:         'application' => '/Application/Application.php',
  48. 48:         'applicationexception' => '/Application/Exceptions/ApplicationException.php',
  49. 49:         'argumentoutofrangeexception' => '/exceptions.php',
  50. 50:         'arraylist' => '/Collections/ArrayList.php',
  51. 51:         'arraytools' => '/ArrayTools.php',
  52. 52:         'authenticationexception' => '/Security/AuthenticationException.php',
  53. 53:         'autoloader' => '/Loaders/AutoLoader.php',
  54. 54:         'badrequestexception' => '/Application/Exceptions/BadRequestException.php',
  55. 55:         'badsignalexception' => '/Application/Exceptions/BadSignalException.php',
  56. 56:         'basetemplate' => '/Templates/BaseTemplate.php',
  57. 57:         'button' => '/Forms/Controls/Button.php',
  58. 58:         'cache' => '/Caching/Cache.php',
  59. 59:         'cachinghelper' => '/Templates/Filters/CachingHelper.php',
  60. 60:         'checkbox' => '/Forms/Controls/Checkbox.php',
  61. 61:         'clirouter' => '/Application/Routers/CliRouter.php',
  62. 62:         'collection' => '/Collections/Collection.php',
  63. 63:         'component' => '/Component.php',
  64. 64:         'componentcontainer' => '/ComponentContainer.php',
  65. 65:         'config' => '/Config/Config.php',
  66. 66:         'configadapterini' => '/Config/ConfigAdapterIni.php',
  67. 67:         'configadapterxml' => '/Config/ConfigAdapterXml.php',
  68. 68:         'configurator' => '/Configurator.php',
  69. 69:         'control' => '/Application/Control.php',
  70. 70:         'conventionalrenderer' => '/Forms/Renderers/ConventionalRenderer.php',
  71. 71:         'curlybracketsfilter' => '/Templates/Filters/LatteFilter.php',
  72. 72:         'curlybracketsmacros' => '/Templates/Filters/LatteFilter.php',
  73. 73:         'debug' => '/Debug.php',
  74. 74:         'deprecatedexception' => '/exceptions.php',
  75. 75:         'directorynotfoundexception' => '/exceptions.php',
  76. 76:         'downloadresponse' => '/Application/Responses/DownloadResponse.php',
  77. 77:         'dummystorage' => '/Caching/DummyStorage.php',
  78. 78:         'environment' => '/Environment.php',
  79. 79:         'fatalerrorexception' => '/exceptions.php',
  80. 80:         'filenotfoundexception' => '/exceptions.php',
  81. 81:         'filestorage' => '/Caching/FileStorage.php',
  82. 82:         'fileupload' => '/Forms/Controls/FileUpload.php',
  83. 83:         'form' => '/Forms/Form.php',
  84. 84:         'formcontainer' => '/Forms/FormContainer.php',
  85. 85:         'formcontrol' => '/Forms/Controls/FormControl.php',
  86. 86:         'formgroup' => '/Forms/FormGroup.php',
  87. 87:         'forwardingresponse' => '/Application/Responses/ForwardingResponse.php',
  88. 88:         'framework' => '/Framework.php',
  89. 89:         'freezableobject' => '/FreezableObject.php',
  90. 90:         'ftp' => '/Web/Ftp.php',
  91. 91:         'ftpexception' => '/Web/Ftp.php',
  92. 92:         'hashtable' => '/Collections/Hashtable.php',
  93. 93:         'hiddenfield' => '/Forms/Controls/HiddenField.php',
  94. 94:         'html' => '/Web/Html.php',
  95. 95:         'httprequest' => '/Web/HttpRequest.php',
  96. 96:         'httpresponse' => '/Web/HttpResponse.php',
  97. 97:         'httpuploadedfile' => '/Web/HttpUploadedFile.php',
  98. 98:         'iauthenticator' => '/Security/IAuthenticator.php',
  99. 99:         'iauthorizator' => '/Security/IAuthorizator.php',
  100. 100:         'icachestorage' => '/Caching/ICacheStorage.php',
  101. 101:         'icollection' => '/Collections/ICollection.php',
  102. 102:         'icomponent' => '/IComponent.php',
  103. 103:         'icomponentcontainer' => '/IComponentContainer.php',
  104. 104:         'iconfigadapter' => '/Config/IConfigAdapter.php',
  105. 105:         'idebuggable' => '/IDebuggable.php',
  106. 106:         'identity' => '/Security/Identity.php',
  107. 107:         'ifiletemplate' => '/Templates/IFileTemplate.php',
  108. 108:         'iformcontrol' => '/Forms/IFormControl.php',
  109. 109:         'iformrenderer' => '/Forms/IFormRenderer.php',
  110. 110:         'ihttprequest' => '/Web/IHttpRequest.php',
  111. 111:         'ihttpresponse' => '/Web/IHttpResponse.php',
  112. 112:         'iidentity' => '/Security/IIdentity.php',
  113. 113:         'ilist' => '/Collections/IList.php',
  114. 114:         'image' => '/Image.php',
  115. 115:         'imagebutton' => '/Forms/Controls/ImageButton.php',
  116. 116:         'imagemagick' => '/ImageMagick.php',
  117. 117:         'imailer' => '/Mail/IMailer.php',
  118. 118:         'imap' => '/Collections/IMap.php',
  119. 119:         'inamingcontainer' => '/Forms/INamingContainer.php',
  120. 120:         'instancefilteriterator' => '/InstanceFilterIterator.php',
  121. 121:         'instantclientscript' => '/Forms/Renderers/InstantClientScript.php',
  122. 122:         'invalidlinkexception' => '/Application/Exceptions/InvalidLinkException.php',
  123. 123:         'invalidpresenterexception' => '/Application/Exceptions/InvalidPresenterException.php',
  124. 124:         'invalidstateexception' => '/exceptions.php',
  125. 125:         'ioexception' => '/exceptions.php',
  126. 126:         'ipartiallyrenderable' => '/Application/IRenderable.php',
  127. 127:         'ipermissionassertion' => '/Security/IPermissionAssertion.php',
  128. 128:         'ipresenter' => '/Application/IPresenter.php',
  129. 129:         'ipresenterloader' => '/Application/IPresenterLoader.php',
  130. 130:         'ipresenterresponse' => '/Application/IPresenterResponse.php',
  131. 131:         'irenderable' => '/Application/IRenderable.php',
  132. 132:         'iresource' => '/Security/IResource.php',
  133. 133:         'irole' => '/Security/IRole.php',
  134. 134:         'irouter' => '/Application/IRouter.php',
  135. 135:         'iservicelocator' => '/IServiceLocator.php',
  136. 136:         'iset' => '/Collections/ISet.php',
  137. 137:         'isignalreceiver' => '/Application/ISignalReceiver.php',
  138. 138:         'istatepersistent' => '/Application/IStatePersistent.php',
  139. 139:         'isubmittercontrol' => '/Forms/ISubmitterControl.php',
  140. 140:         'itemplate' => '/Templates/ITemplate.php',
  141. 141:         'itranslator' => '/ITranslator.php',
  142. 142:         'iuser' => '/Web/IUser.php',
  143. 143:         'jsonresponse' => '/Application/Responses/JsonResponse.php',
  144. 144:         'keynotfoundexception' => '/Collections/Hashtable.php',
  145. 145:         'lattefilter' => '/Templates/Filters/LatteFilter.php',
  146. 146:         'lattemacros' => '/Templates/Filters/LatteMacros.php',
  147. 147:         'limitedscope' => '/Loaders/LimitedScope.php',
  148. 148:         'link' => '/Application/Link.php',
  149. 149:         'mail' => '/Mail/Mail.php',
  150. 150:         'mailmimepart' => '/Mail/MailMimePart.php',
  151. 151:         'memberaccessexception' => '/exceptions.php',
  152. 152:         'memcachedstorage' => '/Caching/MemcachedStorage.php',
  153. 153:         'multirouter' => '/Application/Routers/MultiRouter.php',
  154. 154:         'multiselectbox' => '/Forms/Controls/MultiSelectBox.php',
  155. 155:         'netteloader' => '/Loaders/NetteLoader.php',
  156. 156:         'notimplementedexception' => '/exceptions.php',
  157. 157:         'notsupportedexception' => '/exceptions.php',
  158. 158:         'object' => '/Object.php',
  159. 159:         'objectmixin' => '/ObjectMixin.php',
  160. 160:         'paginator' => '/Paginator.php',
  161. 161:         'permission' => '/Security/Permission.php',
  162. 162:         'presenter' => '/Application/Presenter.php',
  163. 163:         'presentercomponent' => '/Application/PresenterComponent.php',
  164. 164:         'presenterhelpers' => '/Application/PresenterHelpers.php',
  165. 165:         'presenterloader' => '/Application/PresenterLoader.php',
  166. 166:         'presenterrequest' => '/Application/PresenterRequest.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:         'repeatercontrol' => '/Forms/Controls/RepeaterControl.php',
  173. 173:         'robotloader' => '/Loaders/RobotLoader.php',
  174. 174:         'route' => '/Application/Routers/Route.php',
  175. 175:         'rule' => '/Forms/Rule.php',
  176. 176:         'rules' => '/Forms/Rules.php',
  177. 177:         'safestream' => '/IO/SafeStream.php',
  178. 178:         'selectbox' => '/Forms/Controls/SelectBox.php',
  179. 179:         'sendmailmailer' => '/Mail/SendmailMailer.php',
  180. 180:         'servicelocator' => '/ServiceLocator.php',
  181. 181:         'session' => '/Web/Session.php',
  182. 182:         'sessionnamespace' => '/Web/SessionNamespace.php',
  183. 183:         'set' => '/Collections/Set.php',
  184. 184:         'simpleauthenticator' => '/Security/SimpleAuthenticator.php',
  185. 185:         'simpleloader' => '/Loaders/SimpleLoader.php',
  186. 186:         'simplerouter' => '/Application/Routers/SimpleRouter.php',
  187. 187:         'smartcachingiterator' => '/SmartCachingIterator.php',
  188. 188:         'snippethelper' => '/Templates/Filters/SnippetHelper.php',
  189. 189:         'string' => '/String.php',
  190. 190:         'submitbutton' => '/Forms/Controls/SubmitButton.php',
  191. 191:         'template' => '/Templates/Template.php',
  192. 192:         'templatecachestorage' => '/Templates/TemplateCacheStorage.php',
  193. 193:         'templatefilters' => '/Templates/Filters/TemplateFilters.php',
  194. 194:         'templatehelpers' => '/Templates/Filters/TemplateHelpers.php',
  195. 195:         'textarea' => '/Forms/Controls/TextArea.php',
  196. 196:         'textbase' => '/Forms/Controls/TextBase.php',
  197. 197:         'textinput' => '/Forms/Controls/TextInput.php',
  198. 198:         'tools' => '/Tools.php',
  199. 199:         'uri' => '/Web/Uri.php',
  200. 200:         'uriscript' => '/Web/UriScript.php',
  201. 201:         'user' => '/Web/User.php',
  202. 202:         'userclientscript' => '/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 NetteLoader 
  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:             LimitedScope::load($this->base . $this->list[$type]);
  231. 231:             self::$count++;
  232. 232:         }
  233. 233:     }
  234. 234: