Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MINOR Moved ModulePath to GenericTemplateGlobalProvider
- Loading branch information
Showing
2 changed files
with
34 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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))); | ||
} | ||
} | ||
|
||
} | ||
|