本文整理汇总了PHP中Config::unnest方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::unnest方法的具体用法?PHP Config::unnest怎么用?PHP Config::unnest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Config
的用法示例。
在下文中一共展示了Config::unnest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
public function tearDown()
{
$_SERVER['HTTP_HOST'] = $this->oldhost;
Config::unnest();
Email::set_mailer(new Mailer());
parent::tearDown();
}
示例2: tearDown
public function tearDown()
{
Injector::unnest();
SS_Datetime::clear_mock_now();
Config::unnest();
parent::tearDown();
}
示例3: testPermissionFailureSetsCorrectFormMessages
public function testPermissionFailureSetsCorrectFormMessages()
{
Config::nest();
// Controller that doesn't attempt redirections
$controller = new SecurityTest_NullController();
$controller->response = new SS_HTTPResponse();
Security::permissionFailure($controller, array('default' => 'Oops, not allowed'));
$this->assertEquals('Oops, not allowed', Session::get('Security.Message.message'));
// Test that config values are used correctly
Config::inst()->update('Security', 'default_message_set', 'stringvalue');
Security::permissionFailure($controller);
$this->assertEquals('stringvalue', Session::get('Security.Message.message'), 'Default permission failure message value was not present');
Config::inst()->remove('Security', 'default_message_set');
Config::inst()->update('Security', 'default_message_set', array('default' => 'arrayvalue'));
Security::permissionFailure($controller);
$this->assertEquals('arrayvalue', Session::get('Security.Message.message'), 'Default permission failure message value was not present');
// Test that non-default messages work.
// NOTE: we inspect the response body here as the session message has already
// been fetched and output as part of it, so has been removed from the session
$this->logInWithPermission('EDITOR');
Config::inst()->update('Security', 'default_message_set', array('default' => 'default', 'alreadyLoggedIn' => 'You are already logged in!'));
Security::permissionFailure($controller);
$this->assertContains('You are already logged in!', $controller->response->getBody(), 'Custom permission failure message was ignored');
Security::permissionFailure($controller, array('default' => 'default', 'alreadyLoggedIn' => 'One-off failure message'));
$this->assertContains('One-off failure message', $controller->response->getBody(), "Message set passed to Security::permissionFailure() didn't override Config values");
Config::unnest();
}
示例4: tearDown
public function tearDown()
{
AssetStoreTest_SpyStore::reset();
SS_Filesystem::removeFolder($this->getBasePath());
parent::tearDown();
Config::unnest();
}
示例5: tearDown
public function tearDown()
{
while ($this->nestingLevel > 0) {
$this->nestingLevel--;
Config::unnest();
}
parent::tearDown();
}
示例6: getCustomerNote
function getCustomerNote()
{
Config::nest();
Config::inst()->update('SSViewer', 'theme_enabled', true);
$html = $this->renderWith("LogDispatchPhysicalOrderCustomerNote");
Config::unnest();
return $html;
}
示例7: tearDown
public function tearDown()
{
if ($this->oldProcessor) {
SearchUpdater::$processor = $this->oldProcessor;
}
Config::unnest();
Injector::inst()->unregisterNamedObject('QueuedJobService');
FullTextSearch::force_index_list();
parent::tearDown();
}
示例8: forPDF
/**
* Render the object using SSViewer
* @return string
*/
public function forPDF($variables = array())
{
Config::nest();
Config::inst()->update('Director', 'alternate_base_url', static::get_render_host());
$file = $this->owner->getPDFTemplate();
$viewer = new SSViewer($file);
$output = $viewer->process($this->owner, $variables);
Config::unnest();
return $output;
}
示例9: testCustomGetVar
function testCustomGetVar()
{
Config::nest();
Config::inst()->update('MultiForm', 'get_var', 'SuperSessionID');
$form = $this->controller->Form();
$this->assertContains('SuperSessionID', $form::$ignored_fields, "GET var wasn't added to ignored fields");
$this->assertContains('SuperSessionID', $form->FormAction(), "Form action doesn't contain correct session \n\t\t\tID parameter");
$this->assertContains('SuperSessionID', $form->getCurrentStep()->Link(), "Form step doesn't contain correct \n\t\t\tsession ID parameter");
Config::unnest();
}
示例10: tearDown
public function tearDown()
{
if ($this->securityWasEnabled) {
SecurityToken::enable();
} else {
SecurityToken::disable();
}
Injector::unnest();
Config::unnest();
parent::tearDown();
}
示例11: testTruncatesByMaxLength
public function testTruncatesByMaxLength()
{
Config::nest();
Config::inst()->update('FileTextCache_Database', 'max_content_length', 5);
$cache = new FileTextCache_Database();
$file = $this->getMock('File', array('write'));
$content = '0123456789';
$cache->save($file, $content);
$this->assertEquals($cache->load($file), '01234');
Config::unnest();
}
示例12: testFieldPosition
public function testFieldPosition()
{
Config::nest();
Config::inst()->update('MetaTitleExtension', 'InsertBefore', 'MetaDescription');
$testObject = new MetaTitleExtensionTest_DataObject();
$fields = $testObject->getCMSFields();
$descriptionPosition = $fields->fieldPosition('MetaDescription');
$this->assertEquals($descriptionPosition - 1, $fields->fieldPosition('MetaTitle'));
Config::inst()->update('MetaTitleExtension', 'InsertBefore', 'URLSegment');
$fields = $testObject->getCMSFields();
$urlSegmentPosition = $fields->fieldPosition('URLSegment');
$this->assertEquals($urlSegmentPosition - 1, $fields->fieldPosition('MetaTitle'));
Config::unnest();
}
示例13: getTableTitle
function getTableTitle()
{
$tableTitle = _t("Product.UNKNOWN", "Unknown Product");
if ($product = $this->Product()) {
Config::nest();
Config::inst()->update('SSViewer', 'theme_enabled', true);
$tableTitle = strip_tags($product->renderWith("ProductTableTitle"));
Config::unnest();
}
$updatedTableTitle = $this->extend('updateTableTitle', $tableTitle);
if ($updatedTableTitle !== null && is_array($updatedTableTitle) && count($updatedTableTitle)) {
$tableTitle = implode($updatedTableTitle);
}
return $tableTitle;
}
示例14: testDefaultClasses
public function testDefaultClasses()
{
Config::nest();
Config::inst()->update('FormField', 'default_classes', array('class1'));
$field = new FormField('MyField');
$this->assertContains('class1', $field->extraClass(), 'Class list does not contain expected class');
Config::inst()->update('FormField', 'default_classes', array('class1', 'class2'));
$field = new FormField('MyField');
$this->assertContains('class1 class2', $field->extraClass(), 'Class list does not contain expected class');
Config::inst()->update('FormField', 'default_classes', array('class3'));
$field = new FormField('MyField');
$this->assertContains('class3', $field->extraClass(), 'Class list does not contain expected class');
$field->removeExtraClass('class3');
$this->assertNotContains('class3', $field->extraClass(), 'Class list contains unexpected class');
Config::inst()->update('TextField', 'default_classes', array('textfield-class'));
$field = new TextField('MyField');
//check default classes inherit
$this->assertContains('class3', $field->extraClass(), 'Class list does not contain inherited class');
$this->assertContains('textfield-class', $field->extraClass(), 'Class list does not contain expected class');
Config::unnest();
}
示例15: createObject
//.........这里部分代码省略.........
if (isset($data['ID'])) {
$obj->ID = $data['ID'];
// The database needs to allow inserting values into the foreign key column (ID in our case)
$conn = DB::get_conn();
$baseTable = DataObject::getSchema()->baseDataTable($class);
if (method_exists($conn, 'allowPrimaryKeyEditing')) {
$conn->allowPrimaryKeyEditing($baseTable, true);
}
$obj->write(false, true);
if (method_exists($conn, 'allowPrimaryKeyEditing')) {
$conn->allowPrimaryKeyEditing($baseTable, false);
}
}
// Populate defaults
if ($this->defaults) {
foreach ($this->defaults as $fieldName => $fieldVal) {
if (isset($data[$fieldName]) && $data[$fieldName] !== false) {
continue;
}
if (is_callable($fieldVal)) {
$obj->{$fieldName} = $fieldVal($obj, $data, $fixtures);
} else {
$obj->{$fieldName} = $fieldVal;
}
}
}
// Populate overrides
if ($data) {
foreach ($data as $fieldName => $fieldVal) {
// Defer relationship processing
if ($obj->manyManyComponent($fieldName) || $obj->hasManyComponent($fieldName) || $obj->hasOneComponent($fieldName)) {
continue;
}
$this->setValue($obj, $fieldName, $fieldVal, $fixtures);
}
}
$obj->write();
// Save to fixture before relationship processing in case of reflexive relationships
if (!isset($fixtures[$class])) {
$fixtures[$class] = array();
}
$fixtures[$class][$identifier] = $obj->ID;
// Populate all relations
if ($data) {
foreach ($data as $fieldName => $fieldVal) {
if ($obj->manyManyComponent($fieldName) || $obj->hasManyComponent($fieldName)) {
$obj->write();
$parsedItems = array();
if (is_array($fieldVal)) {
// handle lists of many_many relations. Each item can
// specify the many_many_extraFields against each
// related item.
foreach ($fieldVal as $relVal) {
$item = key($relVal);
$id = $this->parseValue($item, $fixtures);
$parsedItems[] = $id;
array_shift($relVal);
$obj->getManyManyComponents($fieldName)->add($id, $relVal);
}
} else {
$items = preg_split('/ *, */', trim($fieldVal));
foreach ($items as $item) {
// Check for correct format: =><relationname>.<identifier>.
// Ignore if the item has already been replaced with a numeric DB identifier
if (!is_numeric($item) && !preg_match('/^=>[^\\.]+\\.[^\\.]+/', $item)) {
throw new InvalidArgumentException(sprintf('Invalid format for relation "%s" on class "%s" ("%s")', $fieldName, $class, $item));
}
$parsedItems[] = $this->parseValue($item, $fixtures);
}
if ($obj->hasManyComponent($fieldName)) {
$obj->getComponents($fieldName)->setByIDList($parsedItems);
} elseif ($obj->manyManyComponent($fieldName)) {
$obj->getManyManyComponents($fieldName)->setByIDList($parsedItems);
}
}
} else {
$hasOneField = preg_replace('/ID$/', '', $fieldName);
if ($className = $obj->hasOneComponent($hasOneField)) {
$obj->{$hasOneField . 'ID'} = $this->parseValue($fieldVal, $fixtures, $fieldClass);
// Inject class for polymorphic relation
if ($className === 'SilverStripe\\ORM\\DataObject') {
$obj->{$hasOneField . 'Class'} = $fieldClass;
}
}
}
}
}
$obj->write();
// If LastEdited was set in the fixture, set it here
if ($data && array_key_exists('LastEdited', $data)) {
$this->overrideField($obj, 'LastEdited', $data['LastEdited'], $fixtures);
}
} catch (Exception $e) {
Config::unnest();
throw $e;
}
Config::unnest();
$this->invokeCallbacks('afterCreate', array($obj, $identifier, &$data, &$fixtures));
return $obj;
}