本文整理汇总了PHP中Drupal\Core\Config\Config::clear方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::clear方法的具体用法?PHP Config::clear怎么用?PHP Config::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Config\Config
的用法示例。
在下文中一共展示了Config::clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testNestedClear
/**
* @covers ::clear
* @dataProvider nestedDataProvider
*/
public function testNestedClear($data)
{
foreach ($data as $key => $value) {
// Check that values are cleared.
$this->config->set($key, $value);
// Check each nested value.
foreach ($value as $nested_key => $nested_value) {
$full_nested_key = $key . '.' . $nested_key;
$this->assertEquals($nested_value, $this->config->get($full_nested_key));
$this->config->clear($full_nested_key);
$this->assertNull($this->config->get($full_nested_key));
}
}
}
示例2: settingsConvertToConfig
/**
* Set config for theme settings, core seems to have forgotten themes can
* have custom settings that you probably very much need in config.
*/
public function settingsConvertToConfig(array $values, Config $config) {
foreach ($values as $key => $value) {
// Save settings as config
if (substr($key, 0, 9) == 'settings_') {
$config_key = Unicode::substr($key, 9);
$config->set('settings.' . $config_key, $value)->save();
}
// Delete suggestions config settings. We do not remove all the suggestions settings
// 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)->save();
}
}
}
}
示例3: deleteConfiguration
/**
* Implements Mollom::deleteConfiguration().
*/
public function deleteConfiguration($name)
{
$name = $this->configuration_map[$name];
$this->config->clear($name)->save();
}