本文整理汇总了PHP中Director::set_environment_type方法的典型用法代码示例。如果您正苦于以下问题:PHP Director::set_environment_type方法的具体用法?PHP Director::set_environment_type怎么用?PHP Director::set_environment_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Director
的用法示例。
在下文中一共展示了Director::set_environment_type方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
parent::setUp();
Director::set_environment_type('dev');
//Check that payment module is installed
$this->assertTrue(class_exists('Payment'), 'Payment module is installed.');
}
示例2: tearDown
function tearDown()
{
parent::tearDown();
ErrorPage::set_static_filepath($this->orig['ErrorPage_staticfilepath']);
Director::set_environment_type($this->orig['Director_environmenttype']);
Filesystem::removeFolder($this->tmpAssetsPath . '/ErrorPageTest');
Filesystem::removeFolder($this->tmpAssetsPath);
}
示例3: run
/**
* Run the task, and do the business
*
* @param SS_HTTPRequest $httpRequest
*/
function run($httpRequest)
{
global $databaseConfig;
// environment type
Director::set_environment_type("dev");
// debug
ini_set("display_errors", "2");
ERROR_REPORTING(E_ALL);
/*
$dbhost = $databaseConfig['server'];
$dbuser = $databaseConfig['username'];
$dbpwd = $databaseConfig['password'];
$dbname = $databaseConfig['database'];
$backupfolder = $_SERVER['DOCUMENT_ROOT'].'/db_backups';
$dumpfile = $backupfolder."/".$dbname."_".date("Y-m-d_H-i-s").".sql";
if (!is_dir($backupfolder)) mkdir($backupfolder);
passthru("/usr/bin/mysqldump --opt --host=$dbhost --user=$dbuser --password=$dbpwd $dbname > $dumpfile");
echo "Created: ".$dumpfile; passthru("tail -1 $dumpfile");
*/
$drop_table_if_exists = false;
//Add MySQL 'DROP TABLE IF EXISTS' Statement To Output
$dbhost = $databaseConfig['server'];
$dbuser = $databaseConfig['username'];
$dbpass = $databaseConfig['password'];
$dbname = $databaseConfig['database'];
$backupfolder = __DIR__ . '/../../db_backups';
$dumpfile = $backupfolder . "/" . $dbname . "_" . date("Y-m-d_H-i-s") . ".sql";
$backup = new MySQLDump();
$backup->droptableifexists = $drop_table_if_exists;
$backup->connect($dbhost, $dbuser, $dbpass, $dbname);
//Connect To Database
if (!$backup->connected) {
die('Error: ' . $backup->mysql_error);
}
//On Failed Connection, Show Error.
$backup->list_tables();
//List Database Tables.
$broj = count($backup->tables);
//Count Database Tables.
$output = '';
echo "found " . $broj . " tables \n\n";
for ($i = 0; $i < $broj; $i++) {
$table_name = $backup->tables[$i];
//Get Table Names.
$backup->dump_table($table_name);
//Dump Data to the Output Buffer.
$output .= $backup->output;
}
if (!is_dir($backupfolder)) {
mkdir($backupfolder);
}
file_put_contents($dumpfile, $output);
echo "Dumped into " . $dumpfile;
//echo "<pre>".$output."</pre>";
}
示例4: testgetRequiredJavaScript_InDev
/**
* Test getCMSFields (basic test)
*/
function testgetRequiredJavaScript_InDev()
{
Director::set_environment_type('dev');
$ol_path = "openlayers/javascript/jsparty/openlayers-2.10/OpenLayers.js";
OpenLayersModel::set_openlayers_path($ol_path);
$obj = new OpenLayersModel();
$jscript = $obj->getRequiredJavaScript();
$this->assertEquals($jscript, $ol_path);
$ol_path = "openlayers/javascript/jsparty/openlayers-2.10/lib/OpenLayers.js";
OpenLayersModel::set_openlayers_path($ol_path);
$obj = new OpenLayersModel();
$jscript = $obj->getRequiredJavaScript();
$this->assertEquals($jscript, $ol_path);
}
示例5: array
<?php
global $TESTING_CONFIG;
$TESTING_CONFIG = array("database" => "{${testing . db . name}}", "reporter" => "{${testing . reporter}}", "logfile" => "{${testing . logdir}}/{${testing . logfile}}");
if (Director::is_cli()) {
Director::set_environment_type('dev');
}
示例6: array
<?php
/**********************
*
* Errors / Dev
*
**********************/
//
//Force enviroment to Dev ** REMOVE FOR LIVE SITES **
Director::set_environment_type("dev");
//
//Force cache to flush on page load if in Dev mode (prevents needing ?flush=1 on the end of a URL)
if (Director::isDev()) {
ini_set('display_errors', 1);
error_reporting(E_ALL);
SSViewer::flush_template_cache();
Debug::log_errors_to('err.log');
}
//(v2.4) Log errors to an email address
//SS_Log::add_writer(new SS_LogEmailWriter('me@mydomain.com'), SS_Log::ERR);
//
//(v2.4) Log errors to a file
//SS_Log::add_writer(new SS_LogFileWriter('error_log.txt'), SS_Log::ERR);
//
/**
* Extended URL rules for the CMS module
*
* @package cms
*/
Director::addRules(50, array('processes//$Action/$ID/$Batch' => 'BatchProcess_Controller', 'admin/help//$Action/$ID' => 'CMSHelp', 'admin/bulkload//$Action/$ID/$OtherID' => 'BulkLoaderAdmin', 'admin/cms//$Action/$ID/$OtherID' => 'CMSMain', 'PageComment//$Action/$ID' => 'PageComment_Controller', 'dev/buildcache/$Action' => 'RebuildStaticCacheTask'));
CMSMenu::add_director_rules();
示例7: parse_url
$_SERVER['SCRIPT_NAME'] = parse_url($url, PHP_URL_PATH);
$_SERVER['REQUEST_PORT'] = parse_url($url, PHP_URL_PORT);
break;
}
$testPath = dirname($testPath);
}
}
if (ManifestBuilder::staleManifest()) {
ManifestBuilder::compileManifest();
}
require_once MANIFEST_FILE;
if (isset($_GET['debugmanifest'])) {
Debug::show(file_get_contents(MANIFEST_FILE));
}
if (!isset(Director::$environment_type)) {
Director::set_environment_type($envType);
}
// Default director
Director::addRules(10, array('Security/$Action' => 'Security', 'db/$Action' => 'DatabaseAdmin', '$Controller/$Action/$ID/$OtherID' => '*', 'images/$Action/$Class/$ID/$Field' => 'Image_Uploader', '' => '->home/', '$URLSegment/$Action/$ID/$OtherID' => 'ModelAsController'));
// Load error handlers
Debug::loadErrorHandlers();
// Connect to database
require_once "core/model/DB.php";
DB::connect($databaseConfig);
// Get the request URL
// $baseURL = dirname(dirname($_SERVER[SCRIPT_NAME]));
$url = $_SERVER['argv'][1];
if (isset($_SERVER['argv'][2])) {
parse_str($_SERVER['argv'][2], $_GET);
$_REQUEST = $_GET;
print_r($_GET);
示例8: testRenderWithSourceFileComments
public function testRenderWithSourceFileComments()
{
$origType = Director::get_environment_type();
Director::set_environment_type('dev');
SSViewer::set_source_file_comments(true);
$view = new SSViewer(array('SSViewerTestCommentsFullSource'));
$data = new ArrayData(array());
$result = $view->process($data);
$expected = '<!doctype html>
<html><!-- template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsFullSource.ss -->
<head></head>
<body></body>
<!-- end template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsFullSource.ss --></html>
';
$this->assertEquals($result, $expected);
$view = new SSViewer(array('SSViewerTestCommentsPartialSource'));
$data = new ArrayData(array());
$result = $view->process($data);
$expected = '<!-- template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsPartialSource.ss -->' . '<div class=\'typography\'></div><!-- end template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsPartialSource.ss -->';
$this->assertEquals($result, $expected);
$view = new SSViewer(array('SSViewerTestCommentsWithInclude'));
$data = new ArrayData(array());
$result = $view->process($data);
$expected = '<!-- template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsWithInclude.ss -->' . '<div class=\'typography\'><!-- include \'SSViewerTestCommentsInclude\' --><!-- template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsInclude.ss -->Included<!-- end template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsInclude.ss -->' . '<!-- end include \'SSViewerTestCommentsInclude\' --></div><!-- end template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsWithInclude.ss -->';
$this->assertEquals($result, $expected);
SSViewer::set_source_file_comments(false);
Director::set_environment_type($origType);
}
示例9: foreach
* @package sapphire
* @subpackage core
*/
/*
* _ss_environment.php handler
*/
if (defined('SS_ENVIRONMENT_FILE')) {
// Only perform valdiation if SS_ENVIRONMENT_FILE is actually set, which is to say, there is an _ss_environment.php file
foreach (array('SS_DATABASE_PASSWORD', 'SS_DATABASE_USERNAME', 'SS_ENVIRONMENT_TYPE') as $reqDefine) {
if (!defined($reqDefine)) {
user_error("{$reqDefine} must be defined in your _ss_environment.php. See http://doc.silverstripe.com/doku.php?id=environment-management for more infomration", E_USER_ERROR);
}
}
}
if (defined('SS_ENVIRONMENT_TYPE')) {
Director::set_environment_type(SS_ENVIRONMENT_TYPE);
}
global $database;
// No database provided
if (!isset($database) || !$database) {
// if SS_DATABASE_CHOOSE_NAME
if (defined('SS_DATABASE_CHOOSE_NAME') && SS_DATABASE_CHOOSE_NAME) {
$loopCount = (int) SS_DATABASE_CHOOSE_NAME;
$databaseDir = dirname($_SERVER['SCRIPT_FILENAME']);
for ($i = 0; $i < $loopCount; $i++) {
$databaseDir = dirname($databaseDir);
}
$database = "SS_" . basename($databaseDir);
$database = str_replace('.', '', $database);
}
}
示例10: array
<?php
global $project;
$project = 'mysite';
global $databaseConfig;
if (strpos($_SERVER['HTTP_HOST'], 'domain.com') === false) {
//dev db
Director::set_environment_type('dev');
$databaseConfig = array("type" => 'MySQLDatabase', "server" => '', "username" => '', "password" => '', "database" => '', "path" => '');
} else {
//prod db
Director::set_environment_type('live');
$databaseConfig = array("type" => 'MySQLDatabase', "server" => '', "username" => '', "password" => '', "database" => '', "path" => '');
}
//require_once('conf/ConfigureFromEnv.php');
Security::setDefaultAdmin('admin', 'password');
MySQLDatabase::set_connection_charset('utf8');
SSViewer::setOption('rewriteHashlinks', false);
Requirements::set_combined_files_enabled(true);
// Set the site locale
i18n::set_locale('en_US');
HtmlEditorConfig::get('cms')->setOptions(array('friendly_name' => 'Default CMS', 'priority' => '100', 'mode' => 'none', 'body_class' => 'typography', 'document_base_url' => '', 'cleanup_callback' => "sapphiremce_cleanup", 'use_native_selects' => true, 'valid_elements' => "@[id|class|style|title],#a[id|rel|rev|dir|tabindex|accesskey|type|name|href|target|title|class],#strong/#b[class],#em/#i[class],#strike[class],#u[class],#p[id|dir|class|align|style],#ol[class],#ul[class],#li[class],br,img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align],#sub[class],#sup[class],#blockquote[dir|class],#table[border=0|cellspacing|cellpadding|width|height|class|align|summary|dir|id|style],#tr[id|dir|class|rowspan|width|height|align|valign|bgcolor|background|bordercolor|style],tbody[id|class|style],thead[id|class|style],tfoot[id|class|style],#td[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],#th[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],caption[id|dir|class],#div[id|dir|class|align|style],#span[class|align|style],#pre[class|align],address[class|align],#h1[id|dir|class|align|style],#h2[id|dir|class|align|style],#h3[id|dir|class|align|style],#h4[id|dir|class|align|style],#h5[id|dir|class|align|style],#h6[id|dir|class|align|style],hr[class],dd[id|class|title|dir],dl[id|class|title|dir],dt[id|class|title|dir],#header[id|class|style|title],#footer[id|class|style|title],#article[id|class|style|title],#aside[id|class|style|title],#section[id|class|style|title],#nav[id|class|style|title],@[id,style,class]", 'extended_valid_elements' => "img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|usemap],iframe[src|name|width|height|align|frameborder|marginwidth|marginheight|scrolling],object[width|height|data|type],param[name|value],map[class|name|id],area[shape|coords|href|target|alt]", 'spellchecker_rpc_url' => THIRDPARTY_DIR . '/tinymce-spellchecker/rpc.php'));
Email::setAdminEmail('noreply@domain.com');
示例11: array
<?php
global $project;
$project = 'mysite';
global $databaseConfig;
$databaseConfig = array("type" => "MySQLDatabase", "server" => "localhost", "username" => "root", "password" => 'root', "database" => "riverfest");
/*$databaseConfig = array(
"type" => "MySQLDatabase",
"server" => "ebro.imu.uiowa.edu:3306",
"username" => "riverfest",
"password" => "ChU6ruju",
"database" => "riverfest",
);*/
// Sites running on the following servers will be
// run in development mode. See
// http://doc.silverstripe.com/doku.php?id=devmode
// for a description of what dev mode does.
Director::set_dev_servers(array('localhost', '127.0.0.1'));
Director::set_environment_type("live");
// This line set's the current theme. More themes can be
// downloaded from http://www.silverstripe.com/themes/
SSViewer::set_theme('riverfest');
示例12: SS_LogFileWriter
Security::setDefaultAdmin('admin', 'admin');
// Log file
SS_Log::add_writer(new SS_LogFileWriter(BASE_PATH . '/../log/staging.log'), SS_Log::WARN, '<=');
break;
default:
case 'production':
Director::set_environment_type("live");
// Log file
SS_Log::add_writer(new SS_LogFileWriter(BASE_PATH . '/../log/production.log'), SS_Log::WARN, '<=');
break;
}
// --------------------------------- //
// Allow override in dev and stage mode for testing asset pipeline
// --------------------------------- //
if (!empty($_GET['env']) && (APPLICATION_ENV == 'staging' || APPLICATION_ENV == 'development')) {
Director::set_environment_type(SS_LoadConf::translate_env($_GET['env']));
}
// --------------------------------- //
// DB
// --------------------------------- //
$databaseConfig = array("type" => 'MySQLDatabase', "server" => $ss_cnf->db->host, "username" => $ss_cnf->db->user, "password" => $ss_cnf->db->pass, "database" => $ss_cnf->db->name, "path" => '');
Config::inst()->update('MySQLDatabase', 'connection_charset', 'utf8');
// --------------------------------- //
// Mail
// --------------------------------- //
SmtpMailer::set_conf($ss_cnf->mail);
// --------------------------------- //
// Misc
// --------------------------------- //
// Set the site locale
i18n::set_locale('en_NZ');
示例13: tearDown
function tearDown()
{
$base = BASE_PATH;
unlink("{$base}/testdata/tests/exec.yml");
Director::set_environment_type($this->envType);
}