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


PHP Config::delete方法代碼示例

本文整理匯總了PHP中Drupal\Core\Config\Config::delete方法的典型用法代碼示例。如果您正苦於以下問題:PHP Config::delete方法的具體用法?PHP Config::delete怎麽用?PHP Config::delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\Core\Config\Config的用法示例。


在下文中一共展示了Config::delete方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testDelete

 /**
  * @covers ::delete
  * @dataProvider overrideDataProvider
  */
 public function testDelete($data, $module_data)
 {
     $this->cacheTagsInvalidator->expects($this->once())->method('invalidateTags')->with(['config:config.test']);
     // Set initial data.
     foreach ($data as $key => $value) {
         $this->config->set($key, $value);
     }
     // Set overrides.
     $this->config->setModuleOverride($module_data);
     // Save.
     $this->config->save();
     // Check that original data is still correct.
     $this->assertOriginalConfigDataEquals($data, FALSE);
     // Check overrides have been set.
     $this->assertConfigDataEquals($module_data);
     $this->assertOriginalConfigDataEquals($module_data, TRUE);
     // Check that config is new.
     $this->assertFalse($this->config->isNew());
     // Delete.
     $this->config->delete();
     // Check object properties have been reset.
     $this->assertTrue($this->config->isNew());
     foreach ($data as $key => $value) {
         $this->assertEmpty($this->config->getOriginal($key, FALSE));
     }
     // Check that overrides have persisted.
     foreach ($module_data as $key => $value) {
         $this->assertConfigDataEquals($module_data);
         $this->assertOriginalConfigDataEquals($module_data, TRUE);
     }
 }
開發者ID:papillon-cendre,項目名稱:d8,代碼行數:35,代碼來源:ConfigTest.php

示例2: testConfigEvents

 /**
  * Tests configuration events.
  */
 function testConfigEvents()
 {
     $name = 'config_events_test.test';
     $config = new Config($name, \Drupal::service('config.storage'), \Drupal::service('event_dispatcher'), \Drupal::service('config.typed'));
     $config->set('key', 'initial');
     \Drupal::state()->get('config_events_test.event', FALSE);
     $this->assertIdentical(\Drupal::state()->get('config_events_test.event', array()), array(), 'No events fired by creating a new configuration object');
     $config->save();
     $event = \Drupal::state()->get('config_events_test.event', array());
     $this->assertIdentical($event['event_name'], ConfigEvents::SAVE);
     $this->assertIdentical($event['current_config_data'], array('key' => 'initial'));
     $this->assertIdentical($event['raw_config_data'], array('key' => 'initial'));
     $this->assertIdentical($event['original_config_data'], array());
     $config->set('key', 'updated')->save();
     $event = \Drupal::state()->get('config_events_test.event', array());
     $this->assertIdentical($event['event_name'], ConfigEvents::SAVE);
     $this->assertIdentical($event['current_config_data'], array('key' => 'updated'));
     $this->assertIdentical($event['raw_config_data'], array('key' => 'updated'));
     $this->assertIdentical($event['original_config_data'], array('key' => 'initial'));
     $config->delete();
     $event = \Drupal::state()->get('config_events_test.event', array());
     $this->assertIdentical($event['event_name'], ConfigEvents::DELETE);
     $this->assertIdentical($event['current_config_data'], array());
     $this->assertIdentical($event['raw_config_data'], array());
     $this->assertIdentical($event['original_config_data'], array('key' => 'updated'));
 }
開發者ID:ddrozdik,項目名稱:dmaps,代碼行數:29,代碼來源:ConfigEventsTest.php

示例3: importConfig

 /**
  * Writes a configuration change from the source to the target storage.
  *
  * @param string $collection
  *   The configuration collection.
  * @param string $op
  *   The change operation.
  * @param string $name
  *   The name of the configuration to process.
  */
 protected function importConfig($collection, $op, $name)
 {
     // Allow config factory overriders to use a custom configuration object if
     // they are responsible for the collection.
     $overrider = $this->configManager->getConfigCollectionInfo()->getOverrideService($collection);
     if ($overrider) {
         $config = $overrider->createConfigObject($name, $collection);
     } else {
         $config = new Config($name, $this->storageComparer->getTargetStorage($collection), $this->eventDispatcher, $this->typedConfigManager);
     }
     if ($op == 'delete') {
         $config->delete();
     } else {
         $data = $this->storageComparer->getSourceStorage($collection)->read($name);
         $config->setData($data ? $data : array());
         $config->save();
     }
     $this->setProcessedConfiguration($collection, $op, $name);
 }
開發者ID:brstde,項目名稱:gap1,代碼行數:29,代碼來源:ConfigImporter.php


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