Feature #25337 ยป 25337_draft.diff

Draft idea - Xavier Perseguers, 2011-06-29 16:12

View differences:

t3lib/class.t3lib_autoloader.php
152 151
	 * @param	string	$className	Class Name
153 152
	 */
154 153
	static protected function attemptToLoadRegistryForGivenClassName($className) {
155
		$classNameParts = explode('_', $className);
156
		$extensionPrefix = array_shift($classNameParts) . '_' . array_shift($classNameParts);
157
		$extensionKey = t3lib_extMgm::getExtensionKeyByPrefix($extensionPrefix);
154
		$extensionKey = '';
155
		$useNamespace = strpos($className, '\\') !== FALSE;
156
		if ($useNamespace) {
157
			$classNameParts = explode('\\', $className);
158
			if ($classNameParts[0] === 't3') {
159
					// Get rid of "t3"
160
				array_shift($classNameParts);
161
				$extensionPrefix = 'tx_' . array_shift($classNameParts);
162
				$extensionKey = t3lib_extMgm::getExtensionKeyByPrefix($extensionPrefix);
163
			}
164
		} else {
165
			$classNameParts = explode('_', $className);
166
			$extensionPrefix = array_shift($classNameParts) . '_' . array_shift($classNameParts);
167
			$extensionKey = t3lib_extMgm::getExtensionKeyByPrefix($extensionPrefix);
168
		}
158 169

  
159 170
		if (!$extensionKey || array_key_exists($extensionKey, self::$extensionHasAutoloadConfiguration)) {
160 171
				// extension key could not be determined or we already tried to load the extension's autoload configuration
t3lib/class.t3lib_div.php
5082 5082
	 * @return	string		Final class name to instantiate with "new [classname]"
5083 5083
	 */
5084 5084
	protected function getClassName($className) {
5085
			// Update class name if a relative namespaced class name is provided
5086
		if (strpos($className, '\\') === FALSE && strpos($className, '_') === FALSE) {
5087
			$traces = debug_backtrace();
5088
				// Find the call to makeInstance
5089
				$pos = 0;
5090
			foreach ($traces as $index => $trace) {
5091
				if ($trace['function'] === 'makeInstance' && $trace['class'] === 't3lib_div') {
5092
					$pos = $index + 1;
5093
					break;
5094
				}
5095
			}
5096
			if ($pos) {
5097
				$callingClassParts = explode('\\', strtolower($traces[$pos]['class']));
5098
				array_pop($callingClassParts);
5099
				$className = implode('\\', $callingClassParts) . '\\' . $className;
5100
			}
5101
		}
5102

  
5085 5103
		if (class_exists($className)) {
5104
				// TODO: Update logic to support XCLASSing, if wanted at all
5086 5105
			while (class_exists('ux_' . $className, FALSE)) {
5087 5106
				$className = 'ux_' . $className;
5088 5107
			}
    (1-1/1)