Problem/Motivation

Deleting a host should delete the composite entity.

Proposed resolution

Implement the entity hooks, support delete.

Comments

miro_dietiker created an issue. See original summary.

miro_dietiker’s picture

Priority: Normal » Major
jmuzz’s picture

Status: Active » Needs review

I might be missing something but I think this is already working.

delete() gets called on each field item in the host entity when it is deleted, and the field type implements it to delete the composite entity in src/Plugin/Field/FieldType/EntityReferenceRevisionsItem.php .

I tested this with a basic setup and the field data inside the paragraph and the row in paragraphs_item were deleted.

miro_dietiker’s picture

Issue tags: +Needs tests

And while the issue was opened in july, it should already work since february...

But i can't see test coverage for it. :-)

jmuzz’s picture

There's something in EntityReferenceRevisionsCompositeTest.php for it.

    // Test that the composite entity is deleted when its parent is deleted.
    $node->delete();
    $this->assertNull(EntityTestCompositeRelationship::load($composite->id()));
miro_dietiker’s picture

Status: Needs review » Closed (works as designed)
Issue tags: -Needs tests

Yeah, great. So we can close this then. :-)