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 https://nette.org
  12. 12:  *
  13. 13:  * @copyright  Copyright (c) 2004, 2009 David Grudl
  14. 14:  * @license    https://nette.org/license  Nette license
  15. 15:  * @link       https://nette.org
  16. 16:  * @category   Nette
  17. 17:  * @package    Nette\Loaders
  18. 18:  * @version    $Id$
  19. 19:  */
  20. 20:  
  21. 21:  
  22. 22:  
  23. 23: require_once dirname(__FILE__'/../Loaders/AutoLoader.php';
  24. 24:  
  25. 25:  
  26. 26:  
  27. 27: /**
  28. 28:  * Nette auto loader is responsible for loading Nette classes and interfaces.
  29. 29:  *
  30. 30:  * @author     David Grudl
  31. 31:  * @copyright  Copyright (c) 2004, 2009 David Grudl
  32. 32:  * @package    Nette\Loaders
  33. 33:  */
  34. 34: class NetteLoader extends AutoLoader
  35. 35: {
  36. 36:     /** @var NetteLoader */
  37. 37:     public static $instance;
  38. 38:  
  39. 39:     /** @var string  base file path */
  40. 40:     public $base;
  41. 41:  
  42. 42:     /** @var array */
  43. 43:     public $list = array(
  44. 44:         'abortexception' => '/Application/AbortException.php',
  45. 45:         'ajaxdriver' => '/Application/AjaxDriver.php',
  46. 46:         'ambiguousserviceexception' => '/ServiceLocator.php',
  47. 47:         'annotations' => '/Annotations.php',
  48. 48:         'appform' => '/Application/AppForm.php',
  49. 49:         'application' => '/Application/Application.php',
  50. 50:         'applicationexception' => '/Application/ApplicationException.php',
  51. 51:         'argumentoutofrangeexception' => '/exceptions.php',
  52. 52:         'arraylist' => '/Collections/ArrayList.php',
  53. 53:         'authenticationexception' => '/Security/AuthenticationException.php',
  54. 54:         'autoloader' => '/Loaders/AutoLoader.php',
  55. 55:         'badrequestexception' => '/Application/BadRequestException.php',
  56. 56:         'badsignalexception' => '/Application/BadSignalException.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:         'collection' => '/Collections/Collection.php',
  62. 62:         'component' => '/Component.php',
  63. 63:         'componentcontainer' => '/ComponentContainer.php',
  64. 64:         'config' => '/Config/Config.php',
  65. 65:         'configadapterini' => '/Config/ConfigAdapterIni.php',
  66. 66:         'configadapterxml' => '/Config/ConfigAdapterXml.php',
  67. 67:         'configurator' => '/Configurator.php',
  68. 68:         'control' => '/Application/Control.php',
  69. 69:         'conventionalrenderer' => '/Forms/Renderers/ConventionalRenderer.php',
  70. 70:         'curlybracketsfilter' => '/Templates/Filters/CurlyBracketsFilter.php',
  71. 71:         'debug' => '/Debug.php',
  72. 72:         'deprecatedexception' => '/exceptions.php',
  73. 73:         'directorynotfoundexception' => '/exceptions.php',
  74. 74:         'dummystorage' => '/Caching/DummyStorage.php',
  75. 75:         'environment' => '/Environment.php',
  76. 76:         'fatalerrorexception' => '/exceptions.php',
  77. 77:         'filenotfoundexception' => '/exceptions.php',
  78. 78:         'filestorage' => '/Caching/FileStorage.php',
  79. 79:         'fileupload' => '/Forms/Controls/FileUpload.php',
  80. 80:         'form' => '/Forms/Form.php',
  81. 81:         'formcontainer' => '/Forms/FormContainer.php',
  82. 82:         'formcontrol' => '/Forms/Controls/FormControl.php',
  83. 83:         'formgroup' => '/Forms/FormGroup.php',
  84. 84:         'forwardingexception' => '/Application/ForwardingException.php',
  85. 85:         'framework' => '/Framework.php',
  86. 86:         'ftp' => '/Web/Ftp.php',
  87. 87:         'ftpexception' => '/Web/Ftp.php',
  88. 88:         'hashtable' => '/Collections/Hashtable.php',
  89. 89:         'hiddenfield' => '/Forms/Controls/HiddenField.php',
  90. 90:         'html' => '/Web/Html.php',
  91. 91:         'httprequest' => '/Web/HttpRequest.php',
  92. 92:         'httpresponse' => '/Web/HttpResponse.php',
  93. 93:         'httpuploadedfile' => '/Web/HttpUploadedFile.php',
  94. 94:         'iajaxdriver' => '/Application/IAjaxDriver.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:         'imap' => '/Collections/IMap.php',
  115. 115:         'inamingcontainer' => '/Forms/INamingContainer.php',
  116. 116:         'instancefilteriterator' => '/InstanceFilterIterator.php',
  117. 117:         'instantclientscript' => '/Forms/Renderers/InstantClientScript.php',
  118. 118:         'invalidlinkexception' => '/Application/InvalidLinkException.php',
  119. 119:         'invalidpresenterexception' => '/Application/InvalidPresenterException.php',
  120. 120:         'invalidstateexception' => '/exceptions.php',
  121. 121:         'ioexception' => '/exceptions.php',
  122. 122:         'ipartiallyrenderable' => '/Application/IRenderable.php',
  123. 123:         'ipermissionassertion' => '/Security/IPermissionAssertion.php',
  124. 124:         'ipresenter' => '/Application/IPresenter.php',
  125. 125:         'ipresenterloader' => '/Application/IPresenterLoader.php',
  126. 126:         'irenderable' => '/Application/IRenderable.php',
  127. 127:         'iresource' => '/Security/IResource.php',
  128. 128:         'irole' => '/Security/IRole.php',
  129. 129:         'irouter' => '/Application/IRouter.php',
  130. 130:         'iservicelocator' => '/IServiceLocator.php',
  131. 131:         'iset' => '/Collections/ISet.php',
  132. 132:         'isignalreceiver' => '/Application/ISignalReceiver.php',
  133. 133:         'istatepersistent' => '/Application/IStatePersistent.php',
  134. 134:         'isubmittercontrol' => '/Forms/ISubmitterControl.php',
  135. 135:         'itemplate' => '/Templates/ITemplate.php',
  136. 136:         'itranslator' => '/ITranslator.php',
  137. 137:         'iuser' => '/Web/IUser.php',
  138. 138:         'javascript' => '/Web/JavaScript.php',
  139. 139:         'javascriptconsole' => '/Web/JavaScriptConsole.php',
  140. 140:         'keynotfoundexception' => '/Collections/Hashtable.php',
  141. 141:         'limitedscope' => '/Loaders/LimitedScope.php',
  142. 142:         'link' => '/Application/Link.php',
  143. 143:         'logger' => '/Logger.php',
  144. 144:         'memberaccessexception' => '/exceptions.php',
  145. 145:         'memcachedstorage' => '/Caching/MemcachedStorage.php',
  146. 146:         'multirouter' => '/Application/MultiRouter.php',
  147. 147:         'multiselectbox' => '/Forms/Controls/MultiSelectBox.php',
  148. 148:         'netteloader' => '/Loaders/NetteLoader.php',
  149. 149:         'notimplementedexception' => '/exceptions.php',
  150. 150:         'notsupportedexception' => '/exceptions.php',
  151. 151:         'object' => '/Object.php',
  152. 152:         'objectmixin' => '/ObjectMixin.php',
  153. 153:         'paginator' => '/Paginator.php',
  154. 154:         'permission' => '/Security/Permission.php',
  155. 155:         'presenter' => '/Application/Presenter.php',
  156. 156:         'presentercomponent' => '/Application/PresenterComponent.php',
  157. 157:         'presenterhelpers' => '/Application/PresenterHelpers.php',
  158. 158:         'presenterloader' => '/Application/PresenterLoader.php',
  159. 159:         'presenterrequest' => '/Application/PresenterRequest.php',
  160. 160:         'radiolist' => '/Forms/Controls/RadioList.php',
  161. 161:         'recursivecomponentiterator' => '/ComponentContainer.php',
  162. 162:         'recursivehtmliterator' => '/Web/Html.php',
  163. 163:         'redirectingexception' => '/Application/RedirectingException.php',
  164. 164:         'repeatercontrol' => '/Forms/Controls/RepeaterControl.php',
  165. 165:         'robotloader' => '/Loaders/RobotLoader.php',
  166. 166:         'route' => '/Application/Route.php',
  167. 167:         'rule' => '/Forms/Rule.php',
  168. 168:         'rules' => '/Forms/Rules.php',
  169. 169:         'safestream' => '/IO/SafeStream.php',
  170. 170:         'selectbox' => '/Forms/Controls/SelectBox.php',
  171. 171:         'servicelocator' => '/ServiceLocator.php',
  172. 172:         'session' => '/Web/Session.php',
  173. 173:         'sessionnamespace' => '/Web/SessionNamespace.php',
  174. 174:         'set' => '/Collections/Set.php',
  175. 175:         'simpleauthenticator' => '/Security/SimpleAuthenticator.php',
  176. 176:         'simpleloader' => '/Loaders/SimpleLoader.php',
  177. 177:         'simplerouter' => '/Application/SimpleRouter.php',
  178. 178:         'smartcachingiterator' => '/SmartCachingIterator.php',
  179. 179:         'snippethelper' => '/Templates/Filters/SnippetHelper.php',
  180. 180:         'string' => '/String.php',
  181. 181:         'submitbutton' => '/Forms/Controls/SubmitButton.php',
  182. 182:         'template' => '/Templates/Template.php',
  183. 183:         'templatecachestorage' => '/Templates/TemplateCacheStorage.php',
  184. 184:         'templatefilters' => '/Templates/Filters/TemplateFilters.php',
  185. 185:         'templatehelpers' => '/Templates/Filters/TemplateHelpers.php',
  186. 186:         'terminateexception' => '/Application/TerminateException.php',
  187. 187:         'textarea' => '/Forms/Controls/TextArea.php',
  188. 188:         'textbase' => '/Forms/Controls/TextBase.php',
  189. 189:         'textinput' => '/Forms/Controls/TextInput.php',
  190. 190:         'tools' => '/Tools.php',
  191. 191:         'uri' => '/Web/Uri.php',
  192. 192:         'uriscript' => '/Web/UriScript.php',
  193. 193:         'user' => '/Web/User.php',
  194. 194:         'userclientscript' => '/Forms/Renderers/UserClientScript.php',
  195. 195:     );
  196. 196:  
  197. 197:  
  198. 198:  
  199. 199:     /**
  200. 200:      * Returns singleton instance with lazy instantiation.
  201. 201:      * @return NetteLoader 
  202. 202:      */
  203. 203:     public static function getInstance()
  204. 204:     {
  205. 205:         if (self::$instance === NULL{
  206. 206:             self::$instance new self;
  207. 207:         }
  208. 208:         return self::$instance;
  209. 209:     }
  210. 210:  
  211. 211:  
  212. 212:  
  213. 213:     /**
  214. 214:      * Handles autoloading of classes or interfaces.
  215. 215:      * @param  string 
  216. 216:      * @return void 
  217. 217:      */
  218. 218:     public function tryLoad($type)
  219. 219:     {
  220. 220:         $type strtolower($type);
  221. 221:         if (isset($this->list[$type])) {
  222. 222:             LimitedScope::load($this->base . $this->list[$type]);
  223. 223:             self::$count++;
  224. 224:         }
  225. 225:     }
  226. 226: