sfCoreAutoload.class.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * The current symfony version.
  11. */
  12. define('SYMFONY_VERSION', '1.1.9');
  13. /**
  14. * sfCoreAutoload class.
  15. *
  16. * This class is a singleton as PHP seems to be unable to register 2 autoloaders that are instances
  17. * of the same class (why?).
  18. *
  19. * @package symfony
  20. * @subpackage autoload
  21. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  22. * @version SVN: $Id: sfCoreAutoload.class.php 20065 2009-07-09 15:02:23Z nicolas $
  23. */
  24. class sfCoreAutoload
  25. {
  26. static protected
  27. $registered = false,
  28. $instance = null;
  29. protected
  30. $baseDir = '';
  31. protected function __construct()
  32. {
  33. $this->baseDir = realpath(dirname(__FILE__).'/..').'/';
  34. }
  35. /**
  36. * Retrieves the singleton instance of this class.
  37. *
  38. * @return sfCoreAutoload A sfCoreAutoload implementation instance.
  39. */
  40. static public function getInstance()
  41. {
  42. if (!isset(self::$instance))
  43. {
  44. self::$instance = new sfCoreAutoload();
  45. }
  46. return self::$instance;
  47. }
  48. /**
  49. * Register sfCoreAutoload in spl autoloader.
  50. *
  51. * @return void
  52. */
  53. static public function register()
  54. {
  55. if (self::$registered)
  56. {
  57. return;
  58. }
  59. ini_set('unserialize_callback_func', 'spl_autoload_call');
  60. if (false === spl_autoload_register(array(self::getInstance(), 'autoload')))
  61. {
  62. throw new sfException(sprintf('Unable to register %s::autoload as an autoloading method.', get_class(self::getInstance())));
  63. }
  64. self::$registered = true;
  65. }
  66. /**
  67. * Unregister sfCoreAutoload from spl autoloader.
  68. *
  69. * @return void
  70. */
  71. static public function unregister()
  72. {
  73. spl_autoload_unregister(array(self::getInstance(), 'autoload'));
  74. self::$registered = false;
  75. }
  76. /**
  77. * Handles autoloading of classes.
  78. *
  79. * @param string $class A class name.
  80. *
  81. * @return boolean Returns true if the class has been loaded
  82. */
  83. public function autoload($class)
  84. {
  85. if (!isset($this->classes[$class]))
  86. {
  87. return false;
  88. }
  89. require $this->baseDir.$this->classes[$class].'/'.$class.'.class.php';
  90. return true;
  91. }
  92. /**
  93. * Rebuilds the association array between class names and paths.
  94. *
  95. * This method overrides this file (__FILE__)
  96. */
  97. static public function make()
  98. {
  99. $libDir = str_replace(DIRECTORY_SEPARATOR, '/', realpath(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'));
  100. require_once $libDir.'/util/sfFinder.class.php';
  101. $files = sfFinder::type('file')
  102. ->prune('plugins')
  103. ->prune('vendor')
  104. ->prune('skeleton')
  105. ->prune('default')
  106. ->name('*\.class\.php')
  107. ->in($libDir)
  108. ;
  109. sort($files, SORT_STRING);
  110. $classes = array();
  111. foreach ($files as $file)
  112. {
  113. $classes[basename($file, '.class.php')] = str_replace($libDir.'/', '', str_replace(DIRECTORY_SEPARATOR, '/', dirname($file)));
  114. }
  115. $content = preg_replace('/protected \$classes = array *\(.*?\)/s', 'protected $classes = '.var_export($classes, true), file_get_contents(__FILE__));
  116. file_put_contents(__FILE__, $content);
  117. }
  118. // Don't edit this property by hand.
  119. // To update it, use sfCoreAutoload::make()
  120. protected $classes = array (
  121. 'sfAction' => 'action',
  122. 'sfActionStack' => 'action',
  123. 'sfActionStackEntry' => 'action',
  124. 'sfActions' => 'action',
  125. 'sfComponent' => 'action',
  126. 'sfComponents' => 'action',
  127. 'sfData' => 'addon',
  128. 'sfPager' => 'addon',
  129. 'sfAutoload' => 'autoload',
  130. 'sfCoreAutoload' => 'autoload',
  131. 'sfSimpleAutoload' => 'autoload',
  132. 'sfAPCCache' => 'cache',
  133. 'sfCache' => 'cache',
  134. 'sfEAcceleratorCache' => 'cache',
  135. 'sfFileCache' => 'cache',
  136. 'sfFunctionCache' => 'cache',
  137. 'sfMemcacheCache' => 'cache',
  138. 'sfNoCache' => 'cache',
  139. 'sfSQLiteCache' => 'cache',
  140. 'sfXCacheCache' => 'cache',
  141. 'sfAnsiColorFormatter' => 'command',
  142. 'sfCommandApplication' => 'command',
  143. 'sfCommandArgument' => 'command',
  144. 'sfCommandArgumentSet' => 'command',
  145. 'sfCommandArgumentsException' => 'command',
  146. 'sfCommandException' => 'command',
  147. 'sfCommandLogger' => 'command',
  148. 'sfCommandManager' => 'command',
  149. 'sfCommandOption' => 'command',
  150. 'sfCommandOptionSet' => 'command',
  151. 'sfFormatter' => 'command',
  152. 'sfSymfonyCommandApplication' => 'command',
  153. 'sfApplicationConfiguration' => 'config',
  154. 'sfAutoloadConfigHandler' => 'config',
  155. 'sfCacheConfigHandler' => 'config',
  156. 'sfCompileConfigHandler' => 'config',
  157. 'sfConfig' => 'config',
  158. 'sfConfigCache' => 'config',
  159. 'sfConfigHandler' => 'config',
  160. 'sfDatabaseConfigHandler' => 'config',
  161. 'sfDefineEnvironmentConfigHandler' => 'config',
  162. 'sfFactoryConfigHandler' => 'config',
  163. 'sfFilterConfigHandler' => 'config',
  164. 'sfGeneratorConfigHandler' => 'config',
  165. 'sfLoader' => 'config',
  166. 'sfProjectConfiguration' => 'config',
  167. 'sfRootConfigHandler' => 'config',
  168. 'sfRoutingConfigHandler' => 'config',
  169. 'sfSecurityConfigHandler' => 'config',
  170. 'sfSimpleYamlConfigHandler' => 'config',
  171. 'sfViewConfigHandler' => 'config',
  172. 'sfYamlConfigHandler' => 'config',
  173. 'sfConsoleController' => 'controller',
  174. 'sfController' => 'controller',
  175. 'sfFrontWebController' => 'controller',
  176. 'sfWebController' => 'controller',
  177. 'sfDatabase' => 'database',
  178. 'sfDatabaseManager' => 'database',
  179. 'sfMySQLDatabase' => 'database',
  180. 'sfMySQLiDatabase' => 'database',
  181. 'sfPDODatabase' => 'database',
  182. 'sfPostgreSQLDatabase' => 'database',
  183. 'sfDebug' => 'debug',
  184. 'sfTimer' => 'debug',
  185. 'sfTimerManager' => 'debug',
  186. 'sfWebDebug' => 'debug',
  187. 'sfEvent' => 'event',
  188. 'sfEventDispatcher' => 'event',
  189. 'sfCacheException' => 'exception',
  190. 'sfConfigurationException' => 'exception',
  191. 'sfControllerException' => 'exception',
  192. 'sfDatabaseException' => 'exception',
  193. 'sfError404Exception' => 'exception',
  194. 'sfException' => 'exception',
  195. 'sfFactoryException' => 'exception',
  196. 'sfFileException' => 'exception',
  197. 'sfFilterException' => 'exception',
  198. 'sfForwardException' => 'exception',
  199. 'sfInitializationException' => 'exception',
  200. 'sfParseException' => 'exception',
  201. 'sfRenderException' => 'exception',
  202. 'sfSecurityException' => 'exception',
  203. 'sfStopException' => 'exception',
  204. 'sfStorageException' => 'exception',
  205. 'sfViewException' => 'exception',
  206. 'sfBasicSecurityFilter' => 'filter',
  207. 'sfCacheFilter' => 'filter',
  208. 'sfCommonFilter' => 'filter',
  209. 'sfExecutionFilter' => 'filter',
  210. 'sfFilter' => 'filter',
  211. 'sfFilterChain' => 'filter',
  212. 'sfRenderingFilter' => 'filter',
  213. 'sfForm' => 'form',
  214. 'sfFormField' => 'form',
  215. 'sfFormFieldSchema' => 'form',
  216. 'sfAdminGenerator' => 'generator',
  217. 'sfCrudGenerator' => 'generator',
  218. 'sfGenerator' => 'generator',
  219. 'sfGeneratorManager' => 'generator',
  220. 'sfRichTextEditor' => 'helper',
  221. 'sfRichTextEditorFCK' => 'helper',
  222. 'sfRichTextEditorTinyMCE' => 'helper',
  223. 'TGettext' => 'i18n/Gettext',
  224. 'sfI18nApplicationExtract' => 'i18n/extract',
  225. 'sfI18nExtract' => 'i18n/extract',
  226. 'sfI18nExtractorInterface' => 'i18n/extract',
  227. 'sfI18nModuleExtract' => 'i18n/extract',
  228. 'sfI18nPhpExtractor' => 'i18n/extract',
  229. 'sfI18nYamlExtractor' => 'i18n/extract',
  230. 'sfI18nYamlGeneratorExtractor' => 'i18n/extract',
  231. 'sfI18nYamlValidateExtractor' => 'i18n/extract',
  232. 'sfChoiceFormat' => 'i18n',
  233. 'sfCultureInfo' => 'i18n',
  234. 'sfDateFormat' => 'i18n',
  235. 'sfDateTimeFormatInfo' => 'i18n',
  236. 'sfI18N' => 'i18n',
  237. 'sfIMessageSource' => 'i18n',
  238. 'sfMessageFormat' => 'i18n',
  239. 'sfMessageSource' => 'i18n',
  240. 'sfMessageSource_Aggregate' => 'i18n',
  241. 'sfMessageSource_Database' => 'i18n',
  242. 'sfMessageSource_File' => 'i18n',
  243. 'sfMessageSource_MySQL' => 'i18n',
  244. 'sfMessageSource_SQLite' => 'i18n',
  245. 'sfMessageSource_XLIFF' => 'i18n',
  246. 'sfMessageSource_gettext' => 'i18n',
  247. 'sfNumberFormat' => 'i18n',
  248. 'sfNumberFormatInfo' => 'i18n',
  249. 'sfAggregateLogger' => 'log',
  250. 'sfConsoleLogger' => 'log',
  251. 'sfFileLogger' => 'log',
  252. 'sfLogger' => 'log',
  253. 'sfLoggerInterface' => 'log',
  254. 'sfLoggerWrapper' => 'log',
  255. 'sfNoLogger' => 'log',
  256. 'sfStreamLogger' => 'log',
  257. 'sfWebDebugLogger' => 'log',
  258. 'sfPearDownloader' => 'plugin',
  259. 'sfPearEnvironment' => 'plugin',
  260. 'sfPearFrontendPlugin' => 'plugin',
  261. 'sfPearRest' => 'plugin',
  262. 'sfPearRest10' => 'plugin',
  263. 'sfPearRest11' => 'plugin',
  264. 'sfPearRestPlugin' => 'plugin',
  265. 'sfPluginDependencyException' => 'plugin',
  266. 'sfPluginException' => 'plugin',
  267. 'sfPluginManager' => 'plugin',
  268. 'sfPluginRecursiveDependencyException' => 'plugin',
  269. 'sfPluginRestException' => 'plugin',
  270. 'sfSymfonyPluginManager' => 'plugin',
  271. 'sfConsoleRequest' => 'request',
  272. 'sfRequest' => 'request',
  273. 'sfWebRequest' => 'request',
  274. 'sfConsoleResponse' => 'response',
  275. 'sfResponse' => 'response',
  276. 'sfWebResponse' => 'response',
  277. 'sfNoRouting' => 'routing',
  278. 'sfPathInfoRouting' => 'routing',
  279. 'sfPatternRouting' => 'routing',
  280. 'sfRouting' => 'routing',
  281. 'sfDatabaseSessionStorage' => 'storage',
  282. 'sfMySQLSessionStorage' => 'storage',
  283. 'sfMySQLiSessionStorage' => 'storage',
  284. 'sfNoStorage' => 'storage',
  285. 'sfPDOSessionStorage' => 'storage',
  286. 'sfPostgreSQLSessionStorage' => 'storage',
  287. 'sfSessionStorage' => 'storage',
  288. 'sfSessionTestStorage' => 'storage',
  289. 'sfStorage' => 'storage',
  290. 'sfCacheClearTask' => 'task/cache',
  291. 'sfConfigureAuthorTask' => 'task/configure',
  292. 'sfConfigureDatabaseTask' => 'task/configure',
  293. 'sfGenerateAppTask' => 'task/generator',
  294. 'sfGenerateModuleTask' => 'task/generator',
  295. 'sfGenerateProjectTask' => 'task/generator',
  296. 'sfGenerateTaskTask' => 'task/generator',
  297. 'sfGeneratorBaseTask' => 'task/generator',
  298. 'sfHelpTask' => 'task/help',
  299. 'sfListTask' => 'task/help',
  300. 'sfI18nExtractTask' => 'task/i18n',
  301. 'sfI18nFindTask' => 'task/i18n',
  302. 'sfLogClearTask' => 'task/log',
  303. 'sfLogRotateTask' => 'task/log',
  304. 'sfPluginAddChannelTask' => 'task/plugin',
  305. 'sfPluginBaseTask' => 'task/plugin',
  306. 'sfPluginInstallTask' => 'task/plugin',
  307. 'sfPluginListTask' => 'task/plugin',
  308. 'sfPluginUninstallTask' => 'task/plugin',
  309. 'sfPluginUpgradeTask' => 'task/plugin',
  310. 'sfProjectClearControllersTask' => 'task/project',
  311. 'sfProjectDeployTask' => 'task/project',
  312. 'sfProjectDisableTask' => 'task/project',
  313. 'sfProjectEnableTask' => 'task/project',
  314. 'sfProjectFreezeTask' => 'task/project',
  315. 'sfProjectPermissionsTask' => 'task/project',
  316. 'sfProjectUnfreezeTask' => 'task/project',
  317. 'sfUpgradeTo11Task' => 'task/project',
  318. 'sfComponentUpgrade' => 'task/project/upgrade1.1',
  319. 'sfConfigFileUpgrade' => 'task/project/upgrade1.1',
  320. 'sfConfigUpgrade' => 'task/project/upgrade1.1',
  321. 'sfEnvironmentUpgrade' => 'task/project/upgrade1.1',
  322. 'sfFactoriesUpgrade' => 'task/project/upgrade1.1',
  323. 'sfFlashUpgrade' => 'task/project/upgrade1.1',
  324. 'sfLayoutUpgrade' => 'task/project/upgrade1.1',
  325. 'sfLoggerUpgrade' => 'task/project/upgrade1.1',
  326. 'sfPropelUpgrade' => 'task/project/upgrade1.1',
  327. 'sfSettingsUpgrade' => 'task/project/upgrade1.1',
  328. 'sfSingletonUpgrade' => 'task/project/upgrade1.1',
  329. 'sfTestUpgrade' => 'task/project/upgrade1.1',
  330. 'sfUpgrade' => 'task/project/upgrade1.1',
  331. 'sfViewCacheManagerUpgrade' => 'task/project/upgrade1.1',
  332. 'sfWebDebugUpgrade' => 'task/project/upgrade1.1',
  333. 'sfBaseTask' => 'task',
  334. 'sfCommandApplicationTask' => 'task',
  335. 'sfFilesystem' => 'task',
  336. 'sfTask' => 'task',
  337. 'sfTestAllTask' => 'task/test',
  338. 'sfTestFunctionalTask' => 'task/test',
  339. 'sfTestUnitTask' => 'task/test',
  340. 'sfTestBrowser' => 'test',
  341. 'sfBasicSecurityUser' => 'user',
  342. 'sfSecurityUser' => 'user',
  343. 'sfUser' => 'user',
  344. 'sfBrowser' => 'util',
  345. 'sfCallable' => 'util',
  346. 'sfContext' => 'util',
  347. 'sfDomCssSelector' => 'util',
  348. 'sfFinder' => 'util',
  349. 'sfInflector' => 'util',
  350. 'sfNamespacedParameterHolder' => 'util',
  351. 'sfParameterHolder' => 'util',
  352. 'sfToolkit' => 'util',
  353. 'sfValidatorI18nChoiceCountry' => 'validator/i18n',
  354. 'sfValidatorI18nChoiceLanguage' => 'validator/i18n',
  355. 'sfValidatorAnd' => 'validator',
  356. 'sfValidatorBase' => 'validator',
  357. 'sfValidatorBoolean' => 'validator',
  358. 'sfValidatorCSRFToken' => 'validator',
  359. 'sfValidatorCallback' => 'validator',
  360. 'sfValidatorChoice' => 'validator',
  361. 'sfValidatorChoiceMany' => 'validator',
  362. 'sfValidatorDate' => 'validator',
  363. 'sfValidatorDateTime' => 'validator',
  364. 'sfValidatorDecorator' => 'validator',
  365. 'sfValidatorEmail' => 'validator',
  366. 'sfValidatorError' => 'validator',
  367. 'sfValidatorErrorSchema' => 'validator',
  368. 'sfValidatorFile' => 'validator',
  369. 'sfValidatorFromDescription' => 'validator',
  370. 'sfValidatorInteger' => 'validator',
  371. 'sfValidatorNumber' => 'validator',
  372. 'sfValidatorOr' => 'validator',
  373. 'sfValidatorPass' => 'validator',
  374. 'sfValidatorRegex' => 'validator',
  375. 'sfValidatorSchema' => 'validator',
  376. 'sfValidatorSchemaCompare' => 'validator',
  377. 'sfValidatorSchemaFilter' => 'validator',
  378. 'sfValidatorSchemaForEach' => 'validator',
  379. 'sfValidatorString' => 'validator',
  380. 'sfValidatorTime' => 'validator',
  381. 'sfValidatorUrl' => 'validator',
  382. 'sfOutputEscaper' => 'view/escaper',
  383. 'sfOutputEscaperArrayDecorator' => 'view/escaper',
  384. 'sfOutputEscaperGetterDecorator' => 'view/escaper',
  385. 'sfOutputEscaperIteratorDecorator' => 'view/escaper',
  386. 'sfOutputEscaperObjectDecorator' => 'view/escaper',
  387. 'sfOutputEscaperSafe' => 'view/escaper',
  388. 'sfPHPView' => 'view',
  389. 'sfPartialView' => 'view',
  390. 'sfView' => 'view',
  391. 'sfViewCacheManager' => 'view',
  392. 'sfViewParameterHolder' => 'view',
  393. 'sfWidgetFormI18nDate' => 'widget/i18n',
  394. 'sfWidgetFormI18nDateTime' => 'widget/i18n',
  395. 'sfWidgetFormI18nSelectCountry' => 'widget/i18n',
  396. 'sfWidgetFormI18nSelectLanguage' => 'widget/i18n',
  397. 'sfWidgetFormI18nTime' => 'widget/i18n',
  398. 'sfWidget' => 'widget',
  399. 'sfWidgetForm' => 'widget',
  400. 'sfWidgetFormDate' => 'widget',
  401. 'sfWidgetFormDateTime' => 'widget',
  402. 'sfWidgetFormInput' => 'widget',
  403. 'sfWidgetFormInputCheckbox' => 'widget',
  404. 'sfWidgetFormInputFile' => 'widget',
  405. 'sfWidgetFormInputHidden' => 'widget',
  406. 'sfWidgetFormInputPassword' => 'widget',
  407. 'sfWidgetFormSchema' => 'widget',
  408. 'sfWidgetFormSchemaDecorator' => 'widget',
  409. 'sfWidgetFormSchemaForEach' => 'widget',
  410. 'sfWidgetFormSchemaFormatter' => 'widget',
  411. 'sfWidgetFormSchemaFormatterList' => 'widget',
  412. 'sfWidgetFormSchemaFormatterTable' => 'widget',
  413. 'sfWidgetFormSelect' => 'widget',
  414. 'sfWidgetFormSelectMany' => 'widget',
  415. 'sfWidgetFormSelectRadio' => 'widget',
  416. 'sfWidgetFormTextarea' => 'widget',
  417. 'sfWidgetFormTime' => 'widget',
  418. 'sfYaml' => 'yaml',
  419. 'sfYamlDumper' => 'yaml',
  420. 'sfYamlInline' => 'yaml',
  421. 'sfYamlParser' => 'yaml',
  422. );
  423. }