From 27b139bc752bfa19b46b1ae9d2ecdce0661c25b4 Mon Sep 17 00:00:00 2001 From: Craig Lyons Date: Fri, 11 Oct 2013 10:18:00 -0400 Subject: [PATCH] Add backwards compatibility for has_extension --- core/Object.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/core/Object.php b/core/Object.php index 3c5480a47..b4251d2db 100755 --- a/core/Object.php +++ b/core/Object.php @@ -470,12 +470,21 @@ abstract class Object { } /** - * Return TRUE if a class has a specified extension - * - * @param string $requiredExtension the class name of the extension to check for. + * 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 $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) { - $class = get_called_class(); + public static function has_extension($classOrExtension, $requiredExtension = null) { + //BC support + if(func_num_args() > 1){ + $class = $classOrExtension; + $requiredExtension = $requiredExtension; + } + else { + $class = get_called_class(); + $requiredExtension = $classOrExtension; + } $requiredExtension = strtolower($requiredExtension); $extensions = Config::inst()->get($class, 'extensions');