mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-28 04:30:08 +02:00
parent
ccdac1a94b
commit
a3c626d0ab
8 changed files with 92 additions and 7 deletions
|
@ -95,4 +95,23 @@ abstract class AttachmentContainingDBElement extends AbstractNamedDBElement impl
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
if ($this->id) {
|
||||
$attachments = $this->attachments;
|
||||
$this->attachments = new ArrayCollection();
|
||||
//Set master attachment is needed
|
||||
foreach ($attachments as $attachment) {
|
||||
$clone = clone $attachment;
|
||||
if ($attachment === $this->master_picture_attachment) {
|
||||
$this->setMasterPictureAttachment($clone);
|
||||
}
|
||||
$this->addAttachment($clone);
|
||||
}
|
||||
}
|
||||
|
||||
//Parent has to be last call, as it resets the ID
|
||||
parent::__clone();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue