/** * Set the environment type of the current site. * * Typically, a SilverStripe site have a number of environments: * - development environments, such a copy on your local machine. * - test sites, such as the one you show the client before going live. * - the live site itself. * * The behaviour of these environments often varies slightly. For example, development sites may have errors dumped to the screen, * and order confirmation emails might be sent to the developer instead of the client. * * To help with this, Sapphire support the notion of an environment type. The environment type can be dev, test, or live. * * You can set it explicitly with Director::set_environment_tpye(). Or you can use {@link Director::set_dev_servers()} and {@link Director::set_test_servers()} * to set it implicitly, based on the value of $_SERVER['HTTP_HOST']. If the HTTP_HOST value is one of the servers listed, then * the environment type will be test or dev. Otherwise, the environment type will be live. * * Dev mode can also be forced by putting ?isDev=1 in your URL, which will ask you to log in and then push the site into dev * mode for the remainder of the session. Putting ?isDev=0 onto the URL can turn it back. * * Test mode can also be forced by putting ?isTest=1 in your URL, which will ask you to log in and then push the site into test * mode for the remainder of the session. Putting ?isTest=0 onto the URL can turn it back. * * Generally speaking, these methods will be called from your _config.php file. * * Once the environment type is set, it can be checked with {@link Director::isDev()}, {@link Director::isTest()}, and * {@link Director::isLive()}. * * @param $et string The environment type: dev, test, or live. */ static function set_environment_type($et) { if ($et != 'dev' && $et != 'test' && $et != 'live') { SS_Backtrace::backtrace(); user_error("Director::set_environment_type passed '{$et}'. It should be passed dev, test, or live", E_USER_WARNING); } else { self::$environment_type = $et; } }
/** * Set the environment type of the current site. * * Typically, a SilverStripe site have a number of environments: * - development environments, such a copy on your local machine. * - test sites, such as the one you show the client before going live. * - the live site itself. * * The behaviour of these environments often varies slightly. For example, development sites may have errors dumped to the screen, * and order confirmation emails might be sent to the developer instead of the client. * * To help with this, Sapphire support the notion of an environment type. The environment type can be dev, test, or live. * * You can set it explicitly with Director::set_environment_tpye(). Or you can use {@link Director::set_dev_servers()} and {@link Director::set_test_servers()} * to set it implicitly, based on the value of $_SERVER['HTTP_HOST']. If the HTTP_HOST value is one of the servers listed, then * the environment type will be test or dev. Otherwise, the environment type will be live. * * Dev mode can also be forced by putting ?isDev=1 in your URL, which will ask you to log in and then push the site into dev * mode for the remainder of the session. Putting ?isDev=0 onto the URL can turn it back. * Generally speaking, these methods will be called from your _config.php file. * * Once the environment type is set, it can be checked with {@link Director::isDev()}, {@link Director::isTest()}, and * {@link Director::isLive()}. * * @param $et string The environment type: dev, test, or live. */ static function set_environment_type($et) { if ($et != 'dev' && $et != 'test' && $et != 'live') { user_error("Director::set_environment_type passed '{$et}'. It should be passed dev, test, or live"); } else { self::$environment_type = $et; } }