Skip to content

[charcoal/attachment] Improve logic for deleting Attachments and descendants #89

@mcaskill

Description

@mcaskill

The CollectionLoader should be used instead of the model factory to benefit from the dynamic type field feature to load the Attachment ID's sub-model.

$attachment = $this->modelFactory()->create(Attachment::class)->load($attachmentId);
$attachment = $this->modelFactory()->create($attachment['type'])->setData($attachment->data());
if ($attachment['id'] !== null) {
$attachment->delete();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions