mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-10 02:14:31 +02:00
Centralized setElement logic for *Attachment entities.
This commit is contained in:
parent
e66fcc85fc
commit
a0c3410db6
14 changed files with 140 additions and 113 deletions
|
@ -33,7 +33,6 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
*/
|
||||
class DeviceAttachment extends Attachment
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Device The element this attachment is associated with.
|
||||
* @ORM\ManyToOne(targetEntity="App\Entity\Devices\Device", inversedBy="attachments")
|
||||
|
@ -41,13 +40,5 @@ class DeviceAttachment extends Attachment
|
|||
*/
|
||||
protected $element;
|
||||
|
||||
public function setElement(AttachmentContainingDBElement $element): Attachment
|
||||
{
|
||||
if (!$element instanceof Device) {
|
||||
throw new \InvalidArgumentException('The element associated with a PartAttachment must be a Device!');
|
||||
}
|
||||
|
||||
$this->element = $element;
|
||||
return $this;
|
||||
}
|
||||
public const ALLOWED_ELEMENT_CLASS = Device::class;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue