Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
namespace DorsetDigital\Themes\Core\Extension;
use SilverStripe\Control\Director;
use SilverStripe\Core\Environment;
use SilverStripe\Core\Extension;
use SilverStripe\View\Requirements;
use SilverStripe\Admin\LeftAndMain;
use SilverStripe\CMS\Controllers\CMSPagesController;
class AdminExtension extends Extension
public function onAfterInit()
$messages = [];
$scriptTpl = <<<EOT
text: '%s',
stay: false,
type: '%s'
if (Director::isDev()) {
$messages[] = [
'level' => 'warn',
'message' => _t(__CLASS__.'.DevModeWarning', 'Notice: This site is currently in development mode. Please ensure that the correct security precautions are in place to protect it.')
if (Director::isLive() && (Environment::getEnv('SS_DEFAULT_ADMIN_PASSWORD') != '')) {
$messages[] = [
'level' => 'warn',
'message' => _t(__CLASS__.'.DefaultAdminWarning', 'Notice: A default administrator password is set in the site config.')
if (!empty($messages)) {
$script = null;
foreach ($messages as $message) {
$script .= sprintf($scriptTpl, $message['message'], $message['level']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.