trait InstanceSettingsTrait in Collapsiblock 4.x
Same name and namespace in other branches
- 3.x tests/src/Traits/InstanceSettingsTrait.php \Drupal\Tests\collapsiblock\Traits\InstanceSettingsTrait
Simplify working with Collapsiblock settings attached to a specific block.
Hierarchy
- trait \Drupal\Tests\collapsiblock\Traits\InstanceSettingsTrait
2 files declare their use of InstanceSettingsTrait
- CollapsiblockFunctionalTestBase.php in tests/
src/ Functional/ CollapsiblockFunctionalTestBase.php - CollapsiblockJavaScriptTestBase.php in tests/
src/ FunctionalJavascript/ CollapsiblockJavaScriptTestBase.php
File
- tests/
src/ Traits/ InstanceSettingsTrait.php, line 10
Namespace
Drupal\Tests\collapsiblock\TraitsView source
trait InstanceSettingsTrait {
/**
* 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 a specific Collapsiblock instance setting.
*
* @param \Drupal\block\BlockInterface $block
* The block instance to get the setting from.
* @param string $key
* The key of the setting to get. Will be automatically prefixed with
* '"third_party.collapsiblock.'.
*
* @return mixed
* The value of the given Collapsiblock block instance setting.
*/
protected function getCollapsiblockBlockInstanceSetting(BlockInterface $block, $key = '') {
return $this
->config($block
->getConfigDependencyName())
->get("third_party_settings.collapsiblock.{$key}");
}
/**
* Set a specific Collapsiblock instance setting.
*
* @param \Drupal\block\BlockInterface $block
* The block instance to change the setting in.
* @param mixed $newValue
* The new value for the setting.
* @param string $key
* The key of the setting to change. Will be automatically prefixed with
* '"third_party.collapsiblock.'.
*/
protected function setCollapsiblockBlockInstanceSetting(BlockInterface $block, $newValue, $key = '') {
$this
->config($block
->getConfigDependencyName())
->set("third_party_settings.collapsiblock.{$key}", $newValue)
->save();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
InstanceSettingsTrait:: |
abstract protected | function | Configuration accessor for tests. Returns non-overridden configuration. | |
InstanceSettingsTrait:: |
protected | function | Get a specific Collapsiblock instance setting. | |
InstanceSettingsTrait:: |
protected | function | Set a specific Collapsiblock instance setting. |