Fixed coding style.

This commit is contained in:
Jan Böhmer 2020-03-15 13:56:31 +01:00
parent 24939f2342
commit fd61c8d9e2
129 changed files with 962 additions and 1091 deletions

View file

@ -365,7 +365,6 @@ abstract class Attachment extends AbstractNamedDBElement
/**
* Sets the element that is associated with this attachment.
*
* @param AttachmentContainingDBElement $element
* @return $this
*/
public function setElement(AttachmentContainingDBElement $element): self
@ -394,7 +393,6 @@ abstract class Attachment extends AbstractNamedDBElement
}
/**
* @param AttachmentType $attachement_type
* @return $this
*/
public function setAttachmentType(AttachmentType $attachement_type): self
@ -408,7 +406,6 @@ abstract class Attachment extends AbstractNamedDBElement
* Sets the url associated with this attachment.
* If the url is empty nothing is changed, to not override the file path.
*
* @param string|null $url
* @return Attachment
*/
public function setURL(?string $url): self

View file

@ -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();
}
}

View file

@ -24,7 +24,6 @@ namespace App\Entity\Attachments;
use App\Entity\Base\AbstractStructuralDBElement;
use App\Entity\Parameters\AttachmentTypeParameter;
use App\Entity\Parameters\DeviceParameter;
use App\Validator\Constraints\ValidFileFilter;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;