PageRenderTime 30ms CodeModel.GetById 19ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/shopaholic/lib/Nette/Loaders/NetteLoader.php

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