public BaseFieldDefinition::setSettings(array $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.
Overrides DataDefinition::setSettings
public function setSettings(array $settings) { // Assign settings individually, in order to keep the current values // of settings not specified in $settings. foreach ($settings as $setting_name => $setting) { $this->getItemDefinition()->setSetting($setting_name, $setting); } return $this; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Field!BaseFieldDefinition.php/function/BaseFieldDefinition::setSettings/8.1.x