MINOR Moved ModulePath to GenericTemplateGlobalProvider

This commit is contained in:
Sean Harvey 2012-04-15 10:48:50 +12:00
parent d7973ea006
commit effc654009
2 changed files with 34 additions and 26 deletions

View File

@ -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

View File

@ -0,0 +1,34 @@
<?php
class GenericTemplateGlobalProvider implements TemplateGlobalProvider {
public static function get_template_global_variables() {
return array(
'ModulePath'
);
}
/**
* @var array Module paths
*/
public static $modules = array(
'framework' => 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)));
}
}
}