本文整理汇总了PHP中Director::get_environment_type方法的典型用法代码示例。如果您正苦于以下问题:PHP Director::get_environment_type方法的具体用法?PHP Director::get_environment_type怎么用?PHP Director::get_environment_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Director
的用法示例。
在下文中一共展示了Director::get_environment_type方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onAfterInit
function onAfterInit()
{
if (in_array(Director::get_environment_type(), Config::inst()->get('FartScrollExtension', 'environmentTypes'))) {
Requirements::javascript('http://code.onion.com/fartscroll.js');
Requirements::customScript('fartscroll(' . Config::inst()->get('FartScrollExtension', 'speed') . ');', 'Fart');
}
}
示例2: BetterNavigator
/**
* Provides a front-end utility menu with administrative functions and developer tools
* Relies on SilverStripeNavigator
*
* @return string
*/
public function BetterNavigator()
{
$isDev = Director::isDev();
if ($isDev || Permission::check('CMS_ACCESS_CMSMain') || Permission::check('VIEW_DRAFT_CONTENT')) {
if ($this->owner && $this->owner->dataRecord) {
//Get SilverStripeNavigator links & stage info (CMS/Stage/Live/Archive)
$nav = array();
$navigator = new SilverStripeNavigator($this->owner->dataRecord);
$items = $navigator->getItems();
foreach ($items as $item) {
$nav[$item->getName()] = array('Link' => $item->getLink(), 'Active' => $item->isActive());
}
//Is the logged in member nominated as a developer?
$member = Member::currentUser();
$devs = Config::inst()->get('BetterNavigator', 'developers');
$isDeveloper = $member && is_array($devs) ? in_array($member->Email, $devs) : false;
//Add other data for template
$nav = array_merge($nav, array('Member' => $member, 'Stage' => Versioned::current_stage(), 'LoginLink' => Config::inst()->get('Security', 'login_url'), 'Mode' => Director::get_environment_type(), 'IsDeveloper' => $isDeveloper));
//Merge with page data, send to template and render
$nav = new ArrayData($nav);
$page = $this->owner->customise($nav);
return $page->renderWith('BetterNavigator');
}
}
return false;
}
示例3: should_compile
/**
* Determines whether this environment should compile meta-languages
*
* @return bool
*/
protected static function should_compile()
{
$config = Config::inst()->forClass("MetaLanguages");
if (!$config->enable_compiling) {
return false;
}
return in_array(Director::get_environment_type(), $config->environments) || in_array($_SERVER['HTTP_HOST'], $config->environments);
}
示例4: get_environment
/**
* Get the payment environment.
* The environment is retrieved from the config yaml file.
* If no environment is specified, assume SilverStripe's environment.
*/
public static function get_environment()
{
if (Config::inst()->get('PaymentGateway', 'environment')) {
return Config::inst()->get('PaymentGateway', 'environment');
} else {
return Director::get_environment_type();
}
}
示例5: setUp
function setUp()
{
parent::setUp();
TestDataController::$data_dir = 'testdata/tests';
$this->envType = Director::get_environment_type();
Director::set_environment_type('test');
TestDataController::$quiet = true;
}
示例6: setUp
function setUp()
{
parent::setUp();
$this->orig['ErrorPage_staticfilepath'] = ErrorPage::get_static_filepath();
$this->tmpAssetsPath = sprintf('%s/_tmp_assets_%s', TEMP_FOLDER, rand());
Filesystem::makeFolder($this->tmpAssetsPath . '/ErrorPageTest');
ErrorPage::set_static_filepath($this->tmpAssetsPath . '/ErrorPageTest');
$this->orig['Director_environmenttype'] = Director::get_environment_type();
Director::set_environment_type('live');
}
示例7: ContactInformations
/**
* @return DataObject
*/
public function ContactInformations()
{
// checks for the active environment type, to load minified css and js files if in live mode
if (Director::get_environment_type() == "dev" || Director::get_environment_type() == "test") {
Requirements::css("widget_Contact/css/contactwidget.css");
} else {
Requirements::css("widget_Contact/css/contactwidget.min.css");
}
return SiteConfig::get()->First();
}
开发者ID:helpfulrobot,项目名称:denkfabrik-neue-medien-silverstripe-widget-contact,代码行数:13,代码来源:ContactWidget.php
示例8: init
/**
* (non-PHPdoc)
* @see sapphire/core/control/ContentController#init()
*/
public function init()
{
parent::init();
// checks for the active environment type, to load minified css and js files if in live mode
if (Director::get_environment_type() == "dev" || Director::get_environment_type() == "test") {
Requirements::css("imprintpage/css/imprint.css");
} else {
Requirements::css("imprintpage/css/imprint.min.css");
}
}
开发者ID:helpfulrobot,项目名称:denkfabrik-neue-medien-silverstripe-imprintpage,代码行数:14,代码来源:ImprintPage.php
示例9: doBootstrap
/**
* @param \Session $session
* @return void
*/
public function doBootstrap(Session $session)
{
if ($this->container === null) {
require_once HEYSTACK_BASE_PATH . '/config/container.php';
$containerClassName = 'HeystackServiceContainer' . \Director::get_environment_type();
$this->container = new $containerClassName();
}
\Injector::inst()->setObjectCreator(new HeystackInjectionCreator($this->container));
$this->container->get(Services::BACKEND_SESSION)->setSession($session);
$this->eventDispatcher = $this->container->get(Services::EVENT_DISPATCHER);
}
示例10: canView
function canView()
{
if (self::$trusted_envs && !in_array(Director::get_environment_type(), self::$trusted_envs)) {
return false;
}
if (self::$trusted_ips && !in_array($_SERVER['REMOTE_ADDR'], self::$trusted_ips)) {
return false;
}
if (!self::$activated) {
return false;
}
return parent::canView();
}
示例11: BetterNavigator
/**
* Provides a front-end utility menu with administrative functions and developer tools
* Relies on SilverStripeNavigator
*
* @return string
*/
public function BetterNavigator()
{
// Make sure this is a page
if (!($this->owner && $this->owner->dataRecord && $this->owner->dataRecord instanceof SiteTree && $this->owner->dataRecord->ID > 0)) {
return false;
}
// Only show navigator to appropriate users
$isDev = Director::isDev();
$canViewDraft = Permission::check('VIEW_DRAFT_CONTENT') || Permission::check('CMS_ACCESS_CMSMain');
if ($isDev || $canViewDraft) {
// Get SilverStripeNavigator links & stage info (CMS/Stage/Live/Archive)
$nav = array();
$viewing = '';
$navigator = new SilverStripeNavigator($this->owner->dataRecord);
$items = $navigator->getItems();
foreach ($items as $item) {
$name = $item->getName();
$active = $item->isActive();
$nav[$name] = array('Link' => $item->getLink(), 'Active' => $active);
if ($active) {
if ($name == 'LiveLink') {
$viewing = 'Live';
}
if ($name == 'StageLink') {
$viewing = 'Draft';
}
if ($name == 'ArchiveLink') {
$viewing = 'Archived';
}
}
}
// Only show edit link if user has permission to edit this page
$editLink = $this->owner->dataRecord->canEdit() && Permission::check('CMS_ACCESS_CMSMain') || $isDev ? $nav['CMSLink']['Link'] : false;
// Is the logged in member nominated as a developer?
$member = Member::currentUser();
$devs = Config::inst()->get('BetterNavigator', 'developers');
$identifierField = Member::config()->unique_identifier_field;
$isDeveloper = $member && is_array($devs) ? in_array($member->{$identifierField}, $devs) : false;
// Add other data for template
$backURL = '?BackURL=' . urlencode($this->owner->Link());
$bNData = array_merge($nav, array('Member' => $member, 'Stage' => Versioned::current_stage(), 'Viewing' => $viewing, 'LoginLink' => Config::inst()->get('Security', 'login_url') . $backURL, 'LogoutLink' => 'Security/logout' . $backURL, 'EditLink' => $editLink, 'Mode' => Director::get_environment_type(), 'IsDeveloper' => $isDeveloper));
// Merge with page data, send to template and render
$bNData = new ArrayData($bNData);
$page = $this->owner->customise(array('BetterNavigator' => $bNData));
return $page->renderWith('BetterNavigator');
}
return false;
}
示例12: execute
/**
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return void
* @throws \Exception
*/
protected function execute(Input\InputInterface $input, Output\OutputInterface $output)
{
if ($input->getOption('dev-build')) {
$output->writeln('Building database');
$databaseAdmin = new \DatabaseAdmin();
$databaseAdmin->doBuild(true);
$output->writeln('Database built');
}
// Get mode
if ($input->getOption('mode')) {
$mode = $input->getOption('mode');
} else {
$mode = \Director::get_environment_type();
}
$container = $this->createContainer();
$this->loadConfig($container, $mode);
$output->writeln($this->dumpContainer($container, $mode, $input->getOption('debug')));
}
示例13: init_authenticator
/**
* Initialises the selected SSPAuthenticator class for SimpleSAMLphp authentication
* @return SSPAuthenticator Active session for authentication
*/
private static function init_authenticator()
{
$authenticators = SSPSecurity::config()->authenticators;
if (!$authenticators || !is_array($authenticators)) {
user_error("Expected array of authentication sources in SSPSecurity::authenticators", E_USER_ERROR);
}
$auth_source = '';
//If set, override authentication sources in config
if (isset($_GET['as'])) {
$auth_source = $_GET['as'];
} else {
$default_auth = SSPSecurity::config()->default_authenticator;
$env = Director::get_environment_type();
if (is_string($default_auth)) {
$auth_source = $default_auth;
} else {
if (is_array($default_auth) && array_key_exists($env, $default_auth)) {
$auth_source = $default_auth[$env];
}
}
}
//If no auth_source is found, default to the first authentication source
if (empty($auth_source)) {
$auth_source = key($authenticators);
}
if (!array_key_exists($auth_source, $authenticators)) {
user_error("'{$auth_source}' does not exist in SSPSecurity::authenticators", E_USER_ERROR);
}
$class = $authenticators[$auth_source];
if (!class_exists($class)) {
user_error("{$class} does not exist", E_USER_ERROR);
}
if (!is_subclass_of($class, 'SSPAuthenticator')) {
user_error("{$class} does not extend from SSPAuthenticator", E_USER_ERROR);
}
return self::create_authenticator($class, $auth_source);
}
示例14: databaseError
public function databaseError($msg, $errorLevel = E_USER_ERROR)
{
// try to extract and format query
if (preg_match('/Couldn\'t run query: ([^\\|]*)\\|\\s*(.*)/', $msg, $matches)) {
$formatter = new SQLFormatter();
$msg = "Couldn't run query: \n" . $formatter->formatPlain($matches[1]) . "\n\n" . $matches[2];
}
$connect_errno = $this->dbConn->connect_errno;
$errno = $this->dbConn->errno;
$sqlstate = $this->dbConn->sqlstate;
$error = $this->dbConn->error;
$connect_error = $msg;
$msg = sprintf('connect_errno : %s - errno : %s - sqlstate : %s - error : %s - connect_error : %s', $connect_errno, $errno, $sqlstate, $error, $connect_error);
SS_Log::log($msg, SS_Log::ERR);
if (Director::get_environment_type() === "live") {
ob_clean();
$maintenance_page = file_get_contents(Director::baseFolder() . '/maintenance/index.html');
echo $maintenance_page;
header("HTTP/1.0 502 Bad Gateway");
exit;
} else {
user_error($msg);
}
}
示例15: index
/**
* Display information when default route is viewed
* Default routes is /dev/healthcheck
*/
public function index()
{
$data = array('Title' => 'Health check', 'Content' => 'Health check content...', 'Environment' => Director::get_environment_type(), 'Mailer' => Email::mailer()->class, 'AdminEmail' => Config::inst()->get('Email', 'admin_email'), 'SendAllEmailsTo' => Config::inst()->get('Email', 'send_all_emails_to'), 'Nofollow' => $this->getRobotsMetaTag(), 'Logging' => $this->getLogWriters(), 'SiteMap' => $this->hasSiteMap(), 'LastCommit' => $this->getLastCommit());
$this->extend('updateIndexData', $data);
return $this->customise($data)->renderWith(array("HealthCheck"));
}