mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Add backwards compatibility for has_extension
This commit is contained in:
parent
829b45af67
commit
27b139bc75
@ -470,12 +470,21 @@ abstract class Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return TRUE if a class has a specified extension
|
* Return TRUE if a class has a specified extension.
|
||||||
*
|
* This supports backwards-compatible format (static Object::has_extension($requiredExtension)) and new format ($object->has_extension($class, $requiredExtension))
|
||||||
* @param string $requiredExtension the class name of the extension to check for.
|
* @param string $classOrExtension if 1 argument supplied, the class name of the extension to check for; if 2 supplied, the class name to test
|
||||||
|
* @param string $requiredExtension used only if 2 arguments supplied
|
||||||
*/
|
*/
|
||||||
public static function has_extension($requiredExtension) {
|
public static function has_extension($classOrExtension, $requiredExtension = null) {
|
||||||
$class = get_called_class();
|
//BC support
|
||||||
|
if(func_num_args() > 1){
|
||||||
|
$class = $classOrExtension;
|
||||||
|
$requiredExtension = $requiredExtension;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$class = get_called_class();
|
||||||
|
$requiredExtension = $classOrExtension;
|
||||||
|
}
|
||||||
|
|
||||||
$requiredExtension = strtolower($requiredExtension);
|
$requiredExtension = strtolower($requiredExtension);
|
||||||
$extensions = Config::inst()->get($class, 'extensions');
|
$extensions = Config::inst()->get($class, 'extensions');
|
||||||
|
Loading…
Reference in New Issue
Block a user