mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-30 13:34:28 +02:00
Fixed coding style.
This commit is contained in:
parent
24939f2342
commit
fd61c8d9e2
129 changed files with 962 additions and 1091 deletions
|
@ -22,8 +22,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Entity\Attachments;
|
||||
|
||||
use App\Entity\Base\MasterAttachmentTrait;
|
||||
use App\Entity\Base\AbstractNamedDBElement;
|
||||
use App\Entity\Base\MasterAttachmentTrait;
|
||||
use App\Entity\Contracts\HasAttachmentsInterface;
|
||||
use App\Entity\Contracts\HasMasterAttachmentInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
@ -39,8 +39,8 @@ abstract class AttachmentContainingDBElement extends AbstractNamedDBElement impl
|
|||
|
||||
/**
|
||||
* @var Attachment[]|Collection
|
||||
* //TODO
|
||||
* //@ORM\OneToMany(targetEntity="Attachment", mappedBy="element")
|
||||
* //TODO
|
||||
* //@ORM\OneToMany(targetEntity="Attachment", mappedBy="element")
|
||||
*
|
||||
* Mapping is done in sub classes like part
|
||||
*/
|
||||
|
@ -51,6 +51,25 @@ abstract class AttachmentContainingDBElement extends AbstractNamedDBElement impl
|
|||
$this->attachments = new ArrayCollection();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
*
|
||||
* Getters
|
||||
|
@ -86,7 +105,6 @@ abstract class AttachmentContainingDBElement extends AbstractNamedDBElement impl
|
|||
/**
|
||||
* Removes the given attachment from this element.
|
||||
*
|
||||
* @param Attachment $attachment
|
||||
* @return $this
|
||||
*/
|
||||
public function removeAttachment(Attachment $attachment): self
|
||||
|
@ -95,23 +113,4 @@ 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