Commit 108c16ad authored by pookmish's avatar pookmish Committed by Berdir
Browse files

Issue #3099997 by pookmish, Postovan Dumitru: $unserializedBehaviorSettings...

Issue #3099997 by pookmish, Postovan Dumitru: $unserializedBehaviorSettings overwrites existing behavior settings
parent 42842d5e
......@@ -221,6 +221,8 @@ class Paragraph extends ContentEntityBase implements ParagraphInterface {
* {@inheritdoc}
*/
public function setBehaviorSettings($plugin_id, array $settings) {
// Get existing behaviors first.
$this->getAllBehaviorSettings();
// Set behavior settings fields.
$this->unserializedBehaviorSettings[$plugin_id] = $settings;
}
......
......@@ -87,6 +87,17 @@ class ParagraphsBehaviorPluginsTest extends KernelTestBase {
$plugin = $paragraph->getParagraphType()->getBehaviorPlugins()->getEnabled();
$this->assertEquals($plugin['test_text_color']->settingsSummary($paragraph)[0], ['label' => 'Text color', 'value' => 'blue']);
// Settings another behavior settings should retain the original behaviors
// from another plugin.
\Drupal::entityTypeManager()->getStorage('paragraph')->resetCache();
$paragraph = Paragraph::load($paragraph->id());
$paragraph->setBehaviorSettings('test_another_id', ['foo' => 'bar']);
$paragraph->save();
$paragraph = Paragraph::load($paragraph->id());
$settings = $paragraph->getAllBehaviorSettings();
$this->assertArrayHasKey('test_text_color', $settings);
$this->assertArrayHasKey('test_another_id', $settings);
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment