当前位置: 首页>>代码示例>>PHP>>正文


PHP Config::save方法代码示例

本文整理汇总了PHP中Drupal\Core\Config\Config::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::save方法的具体用法?PHP Config::save怎么用?PHP Config::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Config\Config的用法示例。


在下文中一共展示了Config::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: import

 /**
  * {@inheritdoc}
  */
 public function import(Row $row, array $old_destination_id_values = array())
 {
     foreach ($row->getRawDestination() as $key => $value) {
         if (isset($value) || !empty($this->configuration['store null'])) {
             $this->config->set(str_replace(Row::PROPERTY_SEPARATOR, '.', $key), $value);
         }
     }
     $this->config->save();
     return [$this->config->getName()];
 }
开发者ID:isramv,项目名称:camp-gdl,代码行数:13,代码来源:Config.php

示例2: import

 /**
  * {@inheritdoc}
  */
 public function import(Row $row, array $old_destination_id_values = array())
 {
     if ($row->hasDestinationProperty('langcode')) {
         $this->config = $this->language_manager->getLanguageConfigOverride($row->getDestinationProperty('langcode'), $this->config->getName());
     }
     foreach ($row->getRawDestination() as $key => $value) {
         if (isset($value) || !empty($this->configuration['store null'])) {
             $this->config->set(str_replace(Row::PROPERTY_SEPARATOR, '.', $key), $value);
         }
     }
     $this->config->save();
     return [$this->config->getName()];
 }
开发者ID:systemick3,项目名称:systemick.co.uk,代码行数:16,代码来源:Config.php

示例3: 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

示例4: 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

示例5: testTagUnicity

 /**
  * Tags should differ between languages and from generic tags.
  */
 public function testTagUnicity()
 {
     // Enable some languages first.
     $this->config->set('language.php.enabled', TRUE);
     $this->config->set('language.python.enabled', TRUE);
     // First round: without format specific tag options.
     $this->config->set('use_format_specific_options', FALSE);
     $this->config->set('tags', 'code blockcode generictag');
     $this->config->save();
     // A language tag should differ from the generic tags.
     $form_values = array('language[php][tags]' => 'php generictag');
     $this->drupalPostForm('admin/config/content/formats/geshifilter/languages/all', $form_values, t('Save configuration'));
     $this->assertText(t('The language tags should differ between languages and from the generic tags.'), t('Language tags should differ from generic tags (with generic tag options)'));
     // Language tags should differ between languages.
     $form_values = array('language[php][tags]' => 'php languagetag', 'language[python][tags]' => 'languagetag python');
     $this->drupalPostForm('admin/config/content/formats/geshifilter/languages/all', $form_values, t('Save configuration'));
     $this->assertText(t('The language tags should differ between languages and from the generic tags.'), t('Language tags should differ between languages (with generic tag options)'));
     // Second round: with format specific tag options.
     // $this->config->set('use_format_specific_options', TRUE);
     // $this->drupalPostForm('admin/config/content/formats/manage/geshifilter_text_format', array(),t('Save configuration'));
     /*$this->config->set('tags_' . $this->input_format_id,
          'code blockcode generictag');
       // A language tag should differ from the generic tags.
       $form_values = array(
         'geshifilter_language_tags_php_' . $this->input_format_id =>
         'php generictag');
       $this->drupalPostForm('admin/config/content/formats/' .
       $this->input_format_id
         . '/configure', $form_values, t('Save configuration'));
       $this->assertText(t('The language tags should differ between languages
         and from the generic tags.'), t('Language tags should differ from
         (with format specific tag options)'));
       // Language tags should differ between languages.
       $form_values = array(
        'geshifilter_language_tags_php_' . $this->input_format_id =>
        'php languagetag',
        'geshifilter_language_tags_python_' . $this->input_format_id =>
        'languagetag python',
       );
       $this->drupalPostForm('admin/config/content/formats/' .
       $this->input_format_id .
         '/configure', $form_values, t('Save configuration'));
       $this->assertText(t('The language tags should differ between languages
         and from the
         generic tags.'), t('Language tags should differ between languages (with
         format specific tag options)'));*/
 }
开发者ID:hugronaphor,项目名称:cornel,代码行数:50,代码来源:GeshiFilterAdministrationTest.php

示例6: skip

 /**
  * Marks the check as skipped. It still can be ran manually, but will remain
  * skipped on the Run & Review page.
  */
 public function skip()
 {
     if (!$this->isSkipped()) {
         $this->config->set('skipped', TRUE);
         $this->config->set('skipped_by', Drupal::currentUser()->id());
         $this->config->set('skipped_on', time());
         $this->config->save();
         // Log.
         $context = array('!name' => $this->getTitle());
         SecurityReview::log($this, '!name check skipped', $context, RfcLogLevel::NOTICE);
     }
 }
开发者ID:AohRveTPV,项目名称:security_review,代码行数:16,代码来源:Check.php

示例7: batchVariableSet

 /**
  * {@inheritdoc}
  */
 public function batchVariableSet(array $variables)
 {
     $state_variables = xmlsitemap_state_variables();
     $config_variables = xmlsitemap_config_variables();
     foreach ($variables as $variable => $value) {
         if (isset($state_variables[$variable])) {
             $this->state->set($variable, $value);
         } else {
             $this->config->set($variable, $value);
         }
     }
     $this->config->save();
 }
开发者ID:jeroenos,项目名称:jeroenos_d8.mypressonline.com,代码行数:16,代码来源:XmlSitemapGenerator.php

示例8: testSpecialChars

 /**
  * Issue https://www.drupal.org/node/2047021.
  */
 public function testSpecialChars()
 {
     $this->config->set('tags', 'code');
     $this->config->set('language.php.enabled', TRUE);
     $this->config->set('decode_entities', TRUE);
     $this->config->save();
     $source = '<code language="php"><?php echo("&lt;b&gt;Hi&lt;/b&gt;"); ?></code>';
     // Create a node.
     $node = array('title' => 'Test for Custom Filter', 'body' => array(array('value' => $source, 'format' => 'geshifilter_text_format')), 'type' => 'geshifilter_content_type');
     $this->drupalCreateNode($node);
     $this->drupalGet('node/1');
     // The same string must be on page, not double encoded.
     $this->assertRaw('&quot;&lt;b&gt;Hi&lt;/b&gt;&quot;', 'The code is not double encoded.');
 }
开发者ID:hugronaphor,项目名称:cornel,代码行数:17,代码来源:GeshiFilterTest.php

示例9: setUp

 /**
  * Code run before each and every test method.
  */
 public function setUp()
 {
     parent::setUp();
     // Create object with configuration.
     $this->config = \Drupal::configFactory()->getEditable('geshifilter.settings');
     // And set the path to the geshi library.
     $this->config->set('geshi_dir', '/libraries/geshi');
     // Create a content type, as we will create nodes on test.
     $settings = array('type' => 'geshifilter_content_type', 'name' => 'Geshifilter Content');
     $this->drupalCreateContentType($settings);
     $this->adminUser = $this->drupalCreateUser(array(), NULL, TRUE);
     // Log in with filter admin user.
     $this->drupalLogin($this->adminUser);
     // Add an text format with only geshi filter.
     $this->createTextFormat('geshifilter_text_format', array('filter_geshifilter'));
     // Set some default GeSHi filter admin settings.
     // Set default highlighting mode to "do nothing".
     $this->config->set('default_highlighting', GeshiFilter::DEFAULT_PLAINTEXT);
     $this->config->set('use_format_specific_options', FALSE);
     $this->config->set('tag_styles', array(GeshiFilter::BRACKETS_ANGLE => GeshiFilter::BRACKETS_ANGLE, GeshiFilter::BRACKETS_SQUARE => GeshiFilter::BRACKETS_SQUARE));
     $this->config->set('default_line_numbering', GeshiFilter::LINE_NUMBERS_DEFAULT_NONE);
     $this->config->save();
 }
开发者ID:hugronaphor,项目名称:cornel,代码行数:26,代码来源:GeshiFieldTest.php

示例10: settingsLayoutConvertToConfig

 /**
  * Set config for theme Layout settings.
  * @param array $values
  * @param \Drupal\Core\Config\Config $config
  */
 public function settingsLayoutConvertToConfig(array $values, Config $config)
 {
     foreach ($values as $key => $value) {
         if (substr($key, 0, 9) == 'settings_') {
             $config_key = Unicode::substr($key, 9);
             $config->set('settings.' . $config_key, $value);
         }
         // Delete suggestions config settings. Do not remove all the suggestions
         // setting because later on if the suggestion is recreated there will be
         // settings for it already which is kind of nice for the user should they
         // accidentally delete a suggestion.
         if (substr($key, 0, 18) == 'delete_suggestion_') {
             $delete_suggestion_key = 'settings.suggestion_' . Unicode::substr($key, 18);
             if ($value == 1) {
                 $config->clear($delete_suggestion_key, $value);
             }
         }
     }
     $config->save();
 }
开发者ID:neetumorwani,项目名称:blogging,代码行数:25,代码来源:ThemeSettingsConfig.php

示例11: 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

示例12: createConfiguration

 /**
  * Creates configuration in a collection based on the provided list.
  *
  * @param string $collection
  *   The configuration collection.
  * @param array $config_to_create
  *   An array of configuration data to create, keyed by name.
  */
 protected function createConfiguration($collection, array $config_to_create)
 {
     // Order the configuration to install in the order of dependencies.
     if ($collection == StorageInterface::DEFAULT_COLLECTION) {
         $dependency_manager = new ConfigDependencyManager();
         $config_names = $dependency_manager->setData($config_to_create)->sortAll();
     } else {
         $config_names = array_keys($config_to_create);
     }
     foreach ($config_names as $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) {
             $new_config = $overrider->createConfigObject($name, $collection);
         } else {
             $new_config = new Config($name, $this->getActiveStorages($collection), $this->eventDispatcher, $this->typedConfig);
         }
         if ($config_to_create[$name] !== FALSE) {
             $new_config->setData($config_to_create[$name]);
         }
         if ($collection == StorageInterface::DEFAULT_COLLECTION && ($entity_type = $this->configManager->getEntityTypeIdByName($name))) {
             // If we are syncing do not create configuration entities. Pluggable
             // configuration entities can have dependencies on modules that are
             // not yet enabled. This approach means that any code that expects
             // default configuration entities to exist will be unstable after the
             // module has been enabled and before the config entity has been
             // imported.
             if ($this->isSyncing()) {
                 continue;
             }
             /** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $entity_storage */
             $entity_storage = $this->configManager->getEntityManager()->getStorage($entity_type);
             // It is possible that secondary writes can occur during configuration
             // creation. Updates of such configuration are allowed.
             if ($this->getActiveStorages($collection)->exists($name)) {
                 $id = $entity_storage->getIDFromConfigName($name, $entity_storage->getEntityType()->getConfigPrefix());
                 $entity = $entity_storage->load($id);
                 $entity = $entity_storage->updateFromStorageRecord($entity, $new_config->get());
             } else {
                 $entity = $entity_storage->createFromStorageRecord($new_config->get());
             }
             if ($entity->isInstallable()) {
                 $entity->trustData()->save();
             }
         } else {
             $new_config->save(TRUE);
         }
     }
 }
开发者ID:dmyerson,项目名称:d8ecs,代码行数:58,代码来源:ConfigInstaller.php

示例13: set

 /**
  * {@inheritdoc}
  */
 public function set($key, $value)
 {
     $this->config->set('settings.' . $key, $value);
     $this->config->save();
     return $this;
 }
开发者ID:AohRveTPV,项目名称:security_review,代码行数:9,代码来源:CheckSettings.php

示例14: createConfiguration

 /**
  * Creates configuration in a collection based on the provided list.
  *
  * @param string $collection
  *   The configuration collection.
  * @param array $config_to_install
  *   A list of configuration object names to create.
  */
 protected function createConfiguration($collection, array $config_to_install)
 {
     // Order the configuration to install in the order of dependencies.
     $data = $this->getSourceStorage($collection)->readMultiple($config_to_install);
     $config_entity_support = $this->configManager->supportsConfigurationEntities($collection);
     if ($config_entity_support) {
         $dependency_manager = new ConfigDependencyManager();
         $config_to_install = $dependency_manager->setData($data)->sortAll();
     }
     // Remove configuration that already exists in the active storage.
     $config_to_install = array_diff($config_to_install, $this->getActiveStorage($collection)->listAll());
     foreach ($config_to_install as $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) {
             $new_config = $overrider->createConfigObject($name, $collection);
         } else {
             $new_config = new Config($name, $this->getActiveStorage($collection), $this->eventDispatcher, $this->typedConfig);
         }
         if ($data[$name] !== FALSE) {
             $new_config->setData($data[$name]);
         }
         if ($config_entity_support && ($entity_type = $this->configManager->getEntityTypeIdByName($name))) {
             // If we are syncing do not create configuration entities. Pluggable
             // configuration entities can have dependencies on modules that are
             // not yet enabled. This approach means that any code that expects
             // default configuration entities to exist will be unstable after the
             // module has been enabled and before the config entity has been
             // imported.
             if ($this->isSyncing) {
                 continue;
             }
             $entity_storage = $this->configManager->getEntityManager()->getStorage($entity_type);
             // It is possible that secondary writes can occur during configuration
             // creation. Updates of such configuration are allowed.
             if ($this->getActiveStorage($collection)->exists($name)) {
                 $id = $entity_storage->getIDFromConfigName($name, $entity_storage->getEntityType()->getConfigPrefix());
                 $entity = $entity_storage->load($id);
                 foreach ($new_config->get() as $property => $value) {
                     $entity->set($property, $value);
                 }
                 $entity->save();
             } else {
                 $entity_storage->create($new_config->get())->save();
             }
         } else {
             $new_config->save();
         }
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:59,代码来源:ConfigInstaller.php

示例15: save

 /**
  * {@inheritdoc}
  */
 public function save($has_trusted_data = FALSE)
 {
     parent::save($has_trusted_data);
     $this->theme->getCache('settings')->deleteAll();
     return $this;
 }
开发者ID:archual,项目名称:drupal_materialize_theme,代码行数:9,代码来源:ThemeSettings.php


注:本文中的Drupal\Core\Config\Config::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。