mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR Moved ModulePath to GenericTemplateGlobalProvider
This commit is contained in:
parent
d7973ea006
commit
effc654009
@ -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
|
||||
|
34
view/GenericTemplateGlobalProvider.php
Normal file
34
view/GenericTemplateGlobalProvider.php
Normal 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)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user