當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Config::unnest方法代碼示例

本文整理匯總了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();
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-comment-notifications,代碼行數:7,代碼來源:CommentNotifierTest.php

示例2: tearDown

 public function tearDown()
 {
     Injector::unnest();
     SS_Datetime::clear_mock_now();
     Config::unnest();
     parent::tearDown();
 }
開發者ID:patricknelson,項目名稱:silverstripe-hybridsessions,代碼行數:7,代碼來源:HybridSessionAbstractTest.php

示例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();
 }
開發者ID:tcaiger,項目名稱:mSupplyNZ,代碼行數:27,代碼來源:SecurityTest.php

示例4: tearDown

 public function tearDown()
 {
     AssetStoreTest_SpyStore::reset();
     SS_Filesystem::removeFolder($this->getBasePath());
     parent::tearDown();
     Config::unnest();
 }
開發者ID:jacobbuck,項目名稱:silverstripe-framework,代碼行數:7,代碼來源:FileMigrationHelperTest.php

示例5: tearDown

 public function tearDown()
 {
     while ($this->nestingLevel > 0) {
         $this->nestingLevel--;
         Config::unnest();
     }
     parent::tearDown();
 }
開發者ID:jacobbuck,項目名稱:silverstripe-framework,代碼行數:8,代碼來源:InjectorTest.php

示例6: getCustomerNote

 function getCustomerNote()
 {
     Config::nest();
     Config::inst()->update('SSViewer', 'theme_enabled', true);
     $html = $this->renderWith("LogDispatchPhysicalOrderCustomerNote");
     Config::unnest();
     return $html;
 }
開發者ID:helpfulrobot,項目名稱:sunnysideup-ecommerce,代碼行數:8,代碼來源:OrderStatusLog_DispatchPhysicalOrder.php

示例7: tearDown

 public function tearDown()
 {
     if ($this->oldProcessor) {
         SearchUpdater::$processor = $this->oldProcessor;
     }
     Config::unnest();
     Injector::inst()->unregisterNamedObject('QueuedJobService');
     FullTextSearch::force_index_list();
     parent::tearDown();
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-fulltextsearch,代碼行數:10,代碼來源:BatchedProcessorTest.php

示例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;
 }
開發者ID:betterbrief,項目名稱:silverstripe-pdf,代碼行數:14,代碼來源:PDFExtension.php

示例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();
 }
開發者ID:tim-lar,項目名稱:silverstripe-multiform,代碼行數:10,代碼來源:MultiFormTest.php

示例10: tearDown

 public function tearDown()
 {
     if ($this->securityWasEnabled) {
         SecurityToken::enable();
     } else {
         SecurityToken::disable();
     }
     Injector::unnest();
     Config::unnest();
     parent::tearDown();
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-spellcheck,代碼行數:11,代碼來源:SpellControllerTest.php

示例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();
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-textextraction,代碼行數:11,代碼來源:FileTextCacheDatabaseTest.php

示例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();
 }
開發者ID:helpfulrobot,項目名稱:kinglozzer-metatitle,代碼行數:14,代碼來源:MetaTitleExtensionTest.php

示例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;
 }
開發者ID:helpfulrobot,項目名稱:sunnysideup-ecommerce,代碼行數:15,代碼來源:Product_OrderItem.php

示例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();
 }
開發者ID:XDdesigners,項目名稱:silverstripe-framework,代碼行數:21,代碼來源:FormFieldTest.php

示例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;
 }
開發者ID:jacobbuck,項目名稱:silverstripe-framework,代碼行數:101,代碼來源:FixtureBlueprint.php


注:本文中的Config::unnest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。