PageRenderTime 1ms CodeModel.GetById 27ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/www/libs/nette-dev/Loaders/NetteLoader.php

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