本文整理汇总了PHP中Director::isTest方法的典型用法代码示例。如果您正苦于以下问题:PHP Director::isTest方法的具体用法?PHP Director::isTest怎么用?PHP Director::isTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Director
的用法示例。
在下文中一共展示了Director::isTest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MetaTags
public function MetaTags(&$tags)
{
if (Director::isDev() or Director::isTest()) {
$tags .= '<meta name="robots" content="noindex, nofollow" />';
}
return $tags;
}
开发者ID:helpfulrobot,项目名称:nobrainerweb-silverstripe-robots-noindex,代码行数:7,代码来源:RobotsNoindexCMSExtensions.php
示例2: forceNonWWW
public static function forceNonWWW()
{
if (!Director::isDev() && !Director::isTest() && strpos($_SERVER['HTTP_HOST'], 'www') === 0) {
$destURL = str_replace(Director::protocol() . 'www.', Director::protocol(), Director::absoluteURL($_SERVER['REQUEST_URI']));
self::force_redirect($destURL);
}
}
示例3: getURLPrefix
public function getURLPrefix()
{
$url = parent::getURLPrefix();
if (Director::isDev() || Director::isTest()) {
$urlarray = parse_url($url);
// define override
if (defined('DEV_SUBSITE_' . Subsite::currentSubsiteID())) {
$subsiteurl = 'DEV_SUBSITE_' . Subsite::currentSubsiteID();
return constant($subsiteurl) . $urlarray['path'];
}
if (!Subsite::currentSubsite() instanceof Subsite) {
return $url;
}
// if set in config settings
$currentDomain = Subsite::currentSubsite()->getPrimarySubsiteDomain();
if (Director::isTest()) {
$currentDomain = Subsite::currentSubsite()->TestDomainID ? Subsite::currentSubsite()->TestDomain() : $currentDomain;
}
if (Director::isDev()) {
$currentDomain = Subsite::currentSubsite()->DevDomainID ? Subsite::currentSubsite()->DevDomain() : $currentDomain;
}
if (!$currentDomain) {
return $url;
}
return $currentDomain->getFullProtocol() . $currentDomain->Domain . $urlarray['path'];
}
return $url;
}
示例4: XrequireDefaultRecords
public function XrequireDefaultRecords()
{
foreach ($this->config()->get('records') as $code => $record) {
if ($record['IsDev'] && Director::isDev() || $record['IsTest'] && Director::isTest() || $record['IsLive'] && Director::isLive()) {
if (!($discountType = StreakDiscountType::get_by_code($code))) {
$discountType = StreakDiscountType::create();
DB::alteration_message("Added discount type '{$code}'", "changed");
}
// if the record is using default code then update from config.
if ($code == self::DefaultCode) {
$record['Code'] = $this->config()->get('default_code');
} else {
$record['Code'] = $code;
}
$title = $record['Title'];
// if the record is using default title then update from config as hasn't changed, if different
// then leave alone
if ($title == self::DefaultTitle) {
$record['Title'] = $this->config()->get('default_title');
}
$data = array_diff_key($record, array_flip(array('IsDev', 'IsTest', 'IsLive')));
$discountType->update($data);
$discountType->write();
}
}
}
示例5: Log
/**
* Log something into our log file
* @param $environment = string (minimum environment state for logging this message)
* @param $message = string (the message body)
**/
static function Log($message = '', $environment = 'dev')
{
// only proceed if LogJam is enabled
if (static::$enabled) {
// make sure our log level matches our environment level, otherwise break out
if (Director::isLive() && $environment != 'live') {
return false;
} else {
if (Director::isTest() && ($environment != 'live' || $environment != 'test')) {
return false;
}
}
// trace the origin call
$trace = SS_Backtrace::filtered_backtrace();
$trace = $trace[0];
$file = isset($trace['file']) ? $trace['file'] : '';
$line = isset($trace['line']) ? $trace['line'] : '';
// construct the line in our file
$output = 'LogJam: ';
$output .= $message;
$output .= ' (line ' . $line . ' in ' . $file . ')';
// piggy-back PHP error_log
return error_log($output);
}
return false;
}
示例6: init
public function init()
{
parent::init();
$this->extend('init');
$canAccess = !Director::isLive() && (Director::isDev() || Director::isTest() || Director::is_cli() || Permission::check("ADMIN"));
if (!$canAccess) {
return Security::permissionFailure($this);
}
Requirements::javascript('framework/thirdparty/jquery/jquery.js');
Requirements::javascript('testsession/javascript/testsession.js');
}
示例7: requireRecords
/**
* @var bool
*
* @throws Exception
*/
public static function requireRecords($force = false)
{
if (self::$ran && !$force) {
return true;
}
self::$ran = true;
if (!(Director::isDev() || Director::isTest())) {
throw new Exception('requireRecords can only be run in development or test environments');
}
$factory = Injector::inst()->create('PopulateFactory');
foreach (self::config()->get('truncate_objects') as $objName) {
$versions = array();
if (class_exists($objName)) {
foreach (DataList::create($objName) as $obj) {
// if the object has the versioned extension, make sure we delete
// that as well
if ($obj->hasExtension('Versioned')) {
foreach ($obj->getVersionedStages() as $stage) {
$versions[$stage] = true;
$obj->deleteFromStage($stage);
}
}
try {
@$obj->delete();
} catch (Exception $e) {
// notice
}
}
}
if ($versions) {
self::truncate_versions($objName, $versions);
}
foreach ((array) ClassInfo::getValidSubClasses($objName) as $table) {
self::truncate_table($table);
self::truncate_versions($table, $versions);
}
self::truncate_table($objName);
}
foreach (self::config()->get('include_yaml_fixtures') as $fixtureFile) {
$fixture = new YamlFixture($fixtureFile);
$fixture->writeInto($factory);
$fixture = null;
}
// hook allowing extensions to clean up records, modify the result or
// export the data to a SQL file (for importing performance).
$static = !(isset($this) && get_class($this) == __CLASS__);
if ($static) {
$populate = Injector::inst()->create('Populate');
} else {
$populate = $this;
}
$populate->extend('onAfterPopulateRecords');
return true;
}
示例8: EnvironmentType
public function EnvironmentType()
{
if (Director::isLive()) {
return "live";
} else {
if (Director::isTest()) {
return "test";
} else {
return "dev";
}
}
}
示例9: contentcontrollerInit
public function contentcontrollerInit($controller)
{
$minicart = Director::isDev() || Director::isTest() ? 'minicart.js' : 'minicart.min.js';
$settings = MiniCart::getMiniCartConfig();
$config = SiteConfig::current_site_config();
Requirements::javascript(MODULE_MINICART_DIR . '/bower_components/minicart/dist/' . $minicart);
Requirements::customScript('paypal.minicart.render(' . $settings . ');', 'minicart');
// reset cart after successful checkout
if (isset($_GET['ppsuccess']) || $this->owner->ID == $config->MiniCartReturnPageID) {
Requirements::customScript('paypal.minicart.reset();', 'minicart_reset');
}
}
示例10: getPiwik
/**
* generates piwik tracking code out of config vars and Piwik.ss template
* @param $wrap wrap inside <script> tags, e.g. for templates
*/
public function getPiwik($wrap = true)
{
if (Director::isDev() && !Config::inst()->get('PiwikExtension', 'show_on_dev')) {
return false;
}
if (Director::isTest() && !Config::inst()->get('PiwikExtension', 'show_on_test')) {
return false;
}
if (Director::isLive() && !Config::inst()->get('PiwikExtension', 'show_on_live')) {
return false;
}
$data = array('WrapInJsTags' => $wrap, 'URL' => Config::inst()->get('PiwikExtension', 'piwik_server'), 'SiteID' => Config::inst()->get('PiwikExtension', 'piwik_site_id'));
return ArrayData::create($data)->renderWith(array('Piwik'));
}
示例11: EnvironmentIcon
public function EnvironmentIcon()
{
if (Director::isLive()) {
$mode = 'live';
} else {
if (Director::isTest()) {
$mode = 'test';
} else {
if (Director::isDev()) {
$mode = 'dev';
}
}
}
return '<span class="environment-icon ' . $mode . '"></span>';
}
示例12: getPiwik
/**
* generates piwik tracking code out of config vars and Piwik.ss template
* @param $wrap wrap inside <script> tags, e.g. for templates
*/
public function getPiwik($wrap = true)
{
if (Director::isDev() && !Config::inst()->get('PiwikExtension', 'show_on_dev')) {
return false;
}
if (Director::isTest() && !Config::inst()->get('PiwikExtension', 'show_on_test')) {
return false;
}
if (Director::isLive() && !Config::inst()->get('PiwikExtension', 'show_on_live')) {
return false;
}
//used for overwriting defaults in SiteConfig, e.g. for different SiteIDs in a Subsite installation
$currentSiteConfig = Controller::curr()->hasMethod('getSiteConfig') ? Controller::curr()->getSiteConfig() : SiteConfig::current_site_config();
$data = array('WrapInJsTags' => $wrap, 'URL' => Config::inst()->get('PiwikExtension', 'piwik_server'), 'SiteID' => Config::inst()->get('PiwikExtension', 'piwik_site_id'), 'SiteConfig' => $currentSiteConfig);
return ArrayData::create($data)->renderWith(array('Piwik'));
}
示例13: init
/**
* Initialisation function that is run before any action on the controller is called.
*
* @uses BasicAuth::requireLogin()
*/
function init() {
// Test and development sites should be secured, via basic-auth
if(Director::isTest() && $this->basicAuthEnabled && Security::database_is_ready()) {
BasicAuth::requireLogin("SilverStripe test website. Use your CMS login", "ADMIN");
}
// Directly access the session variable just in case the Group or Member tables don't yet exist
if(Session::get('loggedInAs') && Security::database_is_ready()) {
if($member = Member::currentUser()) {
Cookie::set("PastMember", true);
DB::query("UPDATE Member SET LastVisited = NOW() WHERE ID = $member->ID", null);
}
}
// This is used to test that subordinate controllers are actually calling parent::init() - a common bug
$this->baseInitCalled = true;
}
示例14: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
if ($this->owner->ID != 0) {
$domains = $this->owner->Domains()->map('ID', 'Domain');
if (Director::isDev() || Director::isTest()) {
if (defined('DEV_SUBSITE_' . $this->owner->ID)) {
$subsiteurl = 'DEV_SUBSITE_' . $this->owner->ID;
$wardingfield = LiteralField::create("WarningDomain", "<p class=\"message warning\">While running in dev or test mode," . " the current domain will be used: <strong>" . constant($subsiteurl) . "</strong></p>");
$fields->addFieldToTab("Root.DomainEnvironments", $wardingfield);
}
}
$fields->addFieldToTab('Root.DomainEnvironments', TextField::create('Live', 'Live', $this->owner->domain())->setReadonly(true));
$fields->addFieldToTab('Root.DomainEnvironments', DropdownField::create('TestDomainID', 'Test', $domains));
$fields->addFieldToTab('Root.DomainEnvironments', DropdownField::create('DevDomainID', 'Dev', $domains));
$fields->makeFieldReadonly('Live');
}
}
示例15: requireRecords
/**
* @var bool
*
* @throws Exception
*/
public static function requireRecords($force = false)
{
if (self::$ran && !$force) {
return true;
}
self::$ran = true;
if (!(Director::isDev() || Director::isTest())) {
throw new Exception('requireRecords can only be run in development or test environments');
}
$factory = Injector::inst()->create('PopulateFactory');
foreach (self::config()->get('truncate_objects') as $objName) {
$versions = array();
if (class_exists($objName)) {
foreach (DataList::create($objName) as $obj) {
// if the object has the versioned extension, make sure we delete
// that as well
if ($obj->hasExtension('Versioned')) {
foreach ($obj->getVersionedStages() as $stage) {
$versions[$stage] = true;
$obj->deleteFromStage($stage);
}
}
try {
@$obj->delete();
} catch (Exception $e) {
// notice
}
}
}
if ($versions) {
self::truncate_versions($objName, $versions);
}
foreach (ClassInfo::getValidSubClasses($objName) as $table) {
self::truncate_table($table);
self::truncate_versions($table, $versions);
}
self::truncate_table($objName);
}
foreach (self::config()->get('include_yaml_fixtures') as $fixtureFile) {
$fixture = new YamlFixture($fixtureFile);
$fixture->writeInto($factory);
$fixture = null;
}
return true;
}