PageRenderTime 15ms CodeModel.GetById 2ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/Nette/Loaders/NetteLoader.php

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