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(); |
|
} |
The
CollectionLoadershould be used instead of the model factory to benefit from the dynamic type field feature to load the Attachment ID's sub-model.charcoal/packages/attachment/src/Charcoal/Admin/Action/RemoveJoinAction.php
Lines 81 to 86 in c72eca8