Extbase:
authorSebastian Kurfürst <sebastian@typo3.org>
Thu, 14 May 2009 07:12:40 +0000 (07:12 +0000)
committerSebastian Kurfürst <sebastian@typo3.org>
Thu, 14 May 2009 07:12:40 +0000 (07:12 +0000)
* The autoloader is now registered in ext_localconf, thus as soon as extbase is installed.

typo3/sysext/extbase/class.tx_extbase_dispatcher.php
typo3/sysext/extbase/ext_localconf.php

index 37b4684..64110e2 100644 (file)
@@ -34,19 +34,6 @@ require_once(t3lib_extMgm::extPath('extbase') . 'Classes/Utility/Strings.php');
  */
 class Tx_Extbase_Dispatcher {
 
-       /**
-        * @var array An array of registered classes (class files with path)
-        */
-       protected $registeredClassNames;
-       
-       /**
-        * Constructs this dispatcher
-        *
-        */
-       public function __construct() {
-               spl_autoload_register(array($this, 'autoLoadClasses'));
-       }
-
        /**
         * Creates a request an dispatches it to a controller.
         *
@@ -143,25 +130,21 @@ class Tx_Extbase_Dispatcher {
         * @uses t3lib_extMgm::extPath()
         * @return void
         */
-       // TODO Remove autoloader as soon as we do not need it anymore
-       public function autoLoadClasses($className) {
-               if (empty($this->registeredClassNames[$className])) {
-                       $classNameParts = explode('_', $className);
-                       $extensionKey = Tx_Extbase_Utility_Strings::camelCaseToLowerCaseUnderscored($classNameParts[1]);
-                       if (t3lib_extMgm::isLoaded($extensionKey)) {
-                               if ($classNameParts[0] === 'ux') {
-                                       array_shift($classNameParts);
-                               }
-                               $className = implode('_', $classNameParts);
-                               if (count($classNameParts) > 2 && $classNameParts[0] === 'Tx') {
-                                       $classFilePathAndName = t3lib_extMgm::extPath(Tx_Extbase_Utility_Strings::camelCaseToLowerCaseUnderscored($classNameParts[1])) . 'Classes/';
-                                       $classFilePathAndName .= implode(array_slice($classNameParts, 2, -1), '/') . '/';
-                                       $classFilePathAndName .= array_pop($classNameParts) . '.php';
-                               }
-                               if (isset($classFilePathAndName) && file_exists($classFilePathAndName)) {
-                                       require_once($classFilePathAndName);
-                                       $this->registeredClassNames[$className] = $classFilePathAndName;
-                               }
+       public static function autoloadClass($className) {
+               $classNameParts = explode('_', $className);
+               $extensionKey = Tx_Extbase_Utility_Strings::camelCaseToLowerCaseUnderscored($classNameParts[1]);
+               if (t3lib_extMgm::isLoaded($extensionKey)) {
+                       if ($classNameParts[0] === 'ux') {
+                               array_shift($classNameParts);
+                       }
+                       $className = implode('_', $classNameParts);
+                       if (count($classNameParts) > 2 && $classNameParts[0] === 'Tx') {
+                               $classFilePathAndName = t3lib_extMgm::extPath(Tx_Extbase_Utility_Strings::camelCaseToLowerCaseUnderscored($classNameParts[1])) . 'Classes/';
+                               $classFilePathAndName .= implode(array_slice($classNameParts, 2, -1), '/') . '/';
+                               $classFilePathAndName .= array_pop($classNameParts) . '.php';
+                       }
+                       if (isset($classFilePathAndName) && file_exists($classFilePathAndName)) {
+                               require_once($classFilePathAndName);
                        }
                }
        }
index d676f76..5c2adca 100644 (file)
@@ -1,5 +1,8 @@
 <?php
 if (!defined ('TYPO3_MODE'))   die ('Access denied.');
 
+require_once(t3lib_extMgm::extPath('extbase') . 'class.tx_extbase_dispatcher.php');
+spl_autoload_register(array('Tx_Extbase_Dispatcher', 'autoloadClass'));
+
 # $GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'EXT:extbase/Classes/Persistence/Hook/TCEMainValueObjectUpdater.php:tx_Extbase_Persistence_Hook_TCEMainValueObjectUpdater';
 ?>
\ No newline at end of file