本文整理匯總了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();
}