Skip to content

Commit

Permalink
MINOR Moved ModulePath to GenericTemplateGlobalProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
halkyon committed Apr 14, 2012
1 parent d7973ea commit effc654
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 26 deletions.
26 changes: 0 additions & 26 deletions control/Controller.php
Expand Up @@ -405,32 +405,6 @@ function can($perm, $member = null) {

//-----------------------------------------------------------------------------------

/**
* 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
Expand Down
34 changes: 34 additions & 0 deletions view/GenericTemplateGlobalProvider.php
@@ -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)));
}
}

}

0 comments on commit effc654

Please sign in to comment.