At the moment we update paragraphs outside an update to the host entity. This resulted in some bugs that are fixed by ๐ Updating paragraph fields is problematic Active however that fix result in an override of the \Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem - which is not great.
In discussion with @Berdir and after creating ๐ Do not create new revisions if the revision ID has changed Active I think we should explore changing paragraphs as part a single update to the host entity. @Berdir pointed out that the code we're likely to want is something like:
$node->get('paragraphs')->entity->set('foo', 'bar');
$node->get('paragraphs)->entity->setNeedsSave(TRUE);
$node->setNewRevision(TRUE);
$node->save()
Obviously that'll need expanding to deal with:
Excerpt of a conversation with @Berdir:
alexpott:
I guess I might need to completely refactor the code (someone elseโs) to get the host entity when changing paragraphs and go that way around. As it feels like ERR is not built to have the paragraphs changed outside of the host entity. Which is fine but the module Iโm fixing doesnโt work that way.
berdir:
> As it feels like ERR is not built to have the paragraphs changed outside of the host entity.
yes, I'd say that's pretty much true. in an ideal world, there probably wouldn't be any separately entities in the first place, just hierarchic json based entity storage or something like that.
Active
1.0
Code