wscott: Patched the director to allow modules to register a function

that will be run on every page load. 


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@41691 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2007-09-14 00:54:02 +00:00
parent 4cb5bd719a
commit 0d80ed0e7b

View File

@ -336,13 +336,35 @@ class Director {
static $siteMode;
static protected $mode_additions;
/**
* Sets the site mode (if it is the public site or the cms),
* and runs registered modules.
*/
static function set_site_mode($mode) {
Director::$siteMode = $mode;
if(isset(self::$mode_additions[$mode]))
foreach(self::$mode_additions[$mode] as $extension) {
call_user_func($extension);
}
}
static function get_site_mode() {
return Director::$siteMode;
}
/**
* Allows a module to register with the director to be run once
* the controller is instantiated. The optional 'mode' parameter
* can be either 'site' or 'cms', as those are the two values currently
* set by controllers. The callback function will be run at the
* initialization of the relavant controller.
*/
static function extend_site($function, $mode='site') {
self::$mode_additions[$mode][] = $function;
}
static protected $environment_type;
/**