trait GlobalSettingsTrait in Collapsiblock 4.x
Same name and namespace in other branches
- 3.x tests/src/Traits/GlobalSettingsTrait.php \Drupal\Tests\collapsiblock\Traits\GlobalSettingsTrait
Simplify working with global Collapsiblock settings.
Hierarchy
- trait \Drupal\Tests\collapsiblock\Traits\GlobalSettingsTrait
2 files declare their use of GlobalSettingsTrait
- CollapsiblockFunctionalTestBase.php in tests/
src/ Functional/ CollapsiblockFunctionalTestBase.php - CollapsiblockJavaScriptTestBase.php in tests/
src/ FunctionalJavascript/ CollapsiblockJavaScriptTestBase.php
File
- tests/
src/ Traits/ GlobalSettingsTrait.php, line 8
Namespace
Drupal\Tests\collapsiblock\TraitsView source
trait GlobalSettingsTrait {
/**
* Configuration accessor for tests. Returns non-overridden configuration.
*
* @param string $name
* Configuration name.
*
* @return \Drupal\Core\Config\Config
* The configuration object with original configuration data.
*/
protected abstract function config($name);
/**
* Get the global Collapsiblock configuration.
*
* @return \Drupal\Core\Config\Config
* The global Collapsiblock configuration object.
*/
protected function getCollapsiblockGlobalConfig() {
return $this
->config('collapsiblock.settings');
}
/**
* Get a specific Collapsiblock global setting.
*
* @param string $key
* The setting to get the value for.
*
* @return mixed
* The given setting's current configuration.
*/
protected function getCollapsiblockGlobalSetting($key = '') {
return $this
->getCollapsiblockGlobalConfig()
->get($key);
}
/**
* Set a specific Collapsiblock global setting.
*
* @param mixed $newValue
* The configuration to set.
* @param string $key
* Which setting to set.
*/
protected function setCollapsiblockGlobalSetting($newValue, $key = '') {
$this
->getCollapsiblockGlobalConfig()
->set($key, $newValue)
->save();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
GlobalSettingsTrait:: |
abstract protected | function | Configuration accessor for tests. Returns non-overridden configuration. | |
GlobalSettingsTrait:: |
protected | function | Get the global Collapsiblock configuration. | |
GlobalSettingsTrait:: |
protected | function | Get a specific Collapsiblock global setting. | |
GlobalSettingsTrait:: |
protected | function | Set a specific Collapsiblock global setting. |