diff --git a/control/Controller.php b/control/Controller.php index 2fde7a873..cd5757edd 100644 --- a/control/Controller.php +++ b/control/Controller.php @@ -405,32 +405,6 @@ class Controller extends RequestHandler implements TemplateGlobalProvider { //----------------------------------------------------------------------------------- - /** - * Given some pre-defined modules, return the filesystem path of the module. - * @param string $name Name of module to find path of - * @return string - */ - function ModulePath($name) { - switch($name) { - case 'framework': - $path = FRAMEWORK_DIR; - break; - case 'frameworkadmin': - $path = FRAMEWORK_ADMIN_DIR; - break; - case 'thirdparty': - $path = THIRDPARTY_DIR; - break; - case 'assets': - $path = ASSETS_DIR; - break; - default: - throw InvalidArgumentException($name . ' is not a supported argument. Possible values: framework, frameworkadmin, thirdparty, assets'); - } - - return $path; - } - /** * returns a date object for use within a template * Usage: $Now.Year - Returns 2006 diff --git a/view/GenericTemplateGlobalProvider.php b/view/GenericTemplateGlobalProvider.php new file mode 100644 index 000000000..422f82c8c --- /dev/null +++ b/view/GenericTemplateGlobalProvider.php @@ -0,0 +1,34 @@ + FRAMEWORK_DIR, + 'frameworkadmin' => FRAMEWORK_ADMIN_DIR, + 'thirdparty' => THIRDPARTY_DIR, + 'assets' => ASSETS_DIR + ); + + /** + * Given some pre-defined modules, return the filesystem path of the module. + * @param string $name Name of module to find path of + * @return string + */ + public static function ModulePath($name) { + if(isset(self::$modules[$name])) { + return self::$modules[$name]; + } else { + throw InvalidArgumentException(sprintf('%s is not a supported argument. Possible values: %s', $name, implode(', ', self::$modules))); + } + } + +} +