public function FieldConfigBase::setSettings in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Field/FieldConfigBase.php \Drupal\Core\Field\FieldConfigBase::setSettings()
- 9 core/lib/Drupal/Core/Field/FieldConfigBase.php \Drupal\Core\Field\FieldConfigBase::setSettings()
Sets field settings.
Note that the method does not unset existing settings not specified in the incoming $settings array.
For example:
// Given these are the default settings.
$field_definition
->getSettings() === [
'fruit' => 'apple',
'season' => 'summer',
];
// Change only the 'fruit' setting.
$field_definition
->setSettings([
'fruit' => 'banana',
]);
// The 'season' setting persists unchanged.
$field_definition
->getSettings() === [
'fruit' => 'banana',
'season' => 'summer',
];
For clarity, it is preferred to use setSetting() if not all available settings are supplied.
Parameters
array $settings: The array of field settings.
Return value
$this
Overrides FieldConfigInterface::setSettings
File
- core/
lib/ Drupal/ Core/ Field/ FieldConfigBase.php, line 352
Class
- FieldConfigBase
- Base class for configurable field definitions.
Namespace
Drupal\Core\FieldCode
public function setSettings(array $settings) {
$this->settings = $settings + $this->settings;
return $this;
}