Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate attachment from original model #32

Open
WimWidgets opened this issue May 7, 2020 · 0 comments
Open

Duplicate attachment from original model #32

WimWidgets opened this issue May 7, 2020 · 0 comments

Comments

@WimWidgets
Copy link

When duplicating an attachment, the attachment of the clone is used as a reference (line 92).

cloner/src/Cloner.php

Lines 89 to 95 in d9c92a1

protected function duplicateAttachments($clone) {
if (!$this->attachment || !method_exists($clone, 'getCloneableFileAttributes')) return;
foreach($clone->getCloneableFileAttributes() as $attribute) {
if (!$original = $clone->getAttribute($attribute)) continue;
$clone->setAttribute($attribute, $this->attachment->duplicate($original));
}
}

This probably doesn't matter in most cases, but it does with the attachment handler I use. This handler will for example generate the path based on properties of the model, like its key/ID. So in my adapter I cannot get the path of the current existing attachment, because the key is different in the clone.

Duplicating from the original model instead of the clone fixes my issue. It also seems more logical to me to duplicate from an original instead from a clone (which should only receive the duplicate).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant