From 655395a8e7784fa90786684cb0764f9e7c4bc3ff Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 1 Oct 2008 14:40:29 +0000 Subject: [PATCH] ENHANCEMENT Added Director::get_environment_type() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63463 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/control/Director.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/control/Director.php b/core/control/Director.php index fb33ab3f1..4ac3a3bb8 100644 --- a/core/control/Director.php +++ b/core/control/Director.php @@ -620,6 +620,23 @@ class Director { self::$environment_type = $et; } } + + /** + * Can also be checked with {@link Director::isDev()}, {@link Director::isTest()}, and {@link Director::isLive()}. + * + * @return string 'dev', 'test' or 'live' + */ + static function get_environment_type() { + if(Director::isLive()) { + return 'live'; + } elseif(Director::isTest()) { + return 'test'; + } elseif(Director::isDev()) { + return 'dev'; + } else { + return false; + } + } /** * Specify HTTP_HOST values that are development environments.