Bug #20029 » makeInstanceWithArgs_v3.diff
t3lib/class.t3lib_div.php (working copy) | ||
---|---|---|
}
|
||
// Get final classname
|
||
$className = t3lib_div::makeInstanceClassName($className);
|
||
$className = self::getClassName($className);
|
||
if (isset($instances[$className])) {
|
||
// it's a singleton, get the existing instance
|
||
$instance = $instances[$className];
|
||
} else {
|
||
$instance = new $className;
|
||
if (func_num_args() > 1) {
|
||
// removing the method's first argument (the class name)
|
||
$constructorArguments = func_get_args();
|
||
array_shift($constructorArguments);
|
||
$reflectedClass = new ReflectionClass($className);
|
||
$instance = $reflectedClass->newInstanceArgs($constructorArguments);
|
||
} else {
|
||
$instance = new $className;
|
||
}
|
||
if ($instance instanceof t3lib_Singleton) {
|
||
// it's a singleton, save the instance for later reuse
|
||
... | ... | |
}
|
||
/**
|
||
* Return classname for new instance, takes the class-extensions API
|
||
* of TYPO3 into account.
|
||
*
|
||
* @param string Base Class name to evaluate
|
||
* @return string Final class name to instantiate with "new [classname]"
|
||
*/
|
||
protected function getClassName($className) {
|
||
return class_exists('ux_'.$className) ? self::getClassName('ux_'.$className) : $className;
|
||
}
|
||
/**
|
||
* Find the best service and check if it works.
|
||
* Returns object of the service class.
|
||
*
|
- « Previous
- 1
- 2
- 3
- Next »