Permalink
Browse files

MINOR Moved ModulePath to GenericTemplateGlobalProvider

  • Loading branch information...
1 parent d7973ea commit effc654009383d734ed3c751bd13e060f75ff7c9 @halkyon halkyon committed Apr 14, 2012
Showing with 34 additions and 26 deletions.
  1. +0 −26 control/Controller.php
  2. +34 −0 view/GenericTemplateGlobalProvider.php
@@ -406,32 +406,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
* @return Date The current date
@@ -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.