When a block has paragraphs, those should be cloned as well because otherwise they point to the same internal id. Setting as a bug report because it's very confusing when editing those blocks.

CommentFileSizeAuthor
#6 3077172-6.patch2.65 KBswentel
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

swentel created an issue. See original summary.

swentel’s picture

Issue summary: View changes
swentel’s picture

Issue summary: View changes
AndyThornton’s picture

Thanks for raising this ticket and your contribution to this module.

Yes, you are right 'probably any entity reference'. While many people use Paragraphs, this issue is likely a problem in other Drupal architectures too. With Drupal 8 us developers/site builders are encouraged to make use of the Entity API, and with convenient tools like Drupal Console making the process easier, it is very feasible and desirable to create custom entities (i.e. particularly for more complex composite field scenario where the Field API strains). We do tend to fall back to Paragraphs for also doing the job that Field Collection helped with in Drupal 7, but, personally, I prefer creating custom entities as architecturally it just keeps things closer to the actual 'real world' that is being modeled (i.e. I can name thing what they are ... rather than thinking of them as a subtype of this thing that is called 'Paragraph').

This is no small task, I am sure - not least that there may be some entity reference that make no sense to clone. For example, if a Block has a reference off to a 'type' that had more info on it - concretely, imagine using a vocab to control a certain thing such as 'document type'. In that case one might only want to clone the reference, not the entity being referenced.

Perhaps they'd be a way to identify these based on their entity reference definition. I am not 100% sure, but maybe if the ER is 'translated' then it implies that it should be cloned, but if it is not translated then it should be cloned.

Another challenge, of course, is how deep do you go? It is not at all unfeasible to think of a Block containing a Paragraph and that Paragraph contain a Media entity ...

swentel’s picture

Yep, this is going to be challenging indeed.

To prepare for it, #3077352: Take over SetInlineBlockDependency is a first step since that helps paragraphs already too.

swentel’s picture

Status: Active » Needs review
FileSize
2.65 KB

First take. Fixes a bug too for inline usage.

This adds support for entity_reference_revisions (currently our major problem at a project)

  • swentel committed 5d9a879 on 8.x-2.x
    Issue #3077172 by swentel: Support for cloning paragraphs (and probably...
swentel’s picture

I've committed the patch already so we can use the dev release for further testing.

Still todo:

- add tests
- which other types are we going to support
- should there be a fallback? e.g. the cloning of the reference fails, so it's probably better to clear the values of the cloned parent
- recursive ?

swentel’s picture

Status: Needs review » Fixed

Closing this as this works fine for us right now. Adding tests is a bit complex at the moment, if weird things popup, I'll get to that then :)
I'll open new issues (or others can) if new cases come up too.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.