mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-24 04:44:35 +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
|
@ -28,6 +28,7 @@ use App\Entity\Parts\MeasurementUnit;
|
|||
use App\Entity\Parts\Part;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\HttpKernel\HttpCache\Store;
|
||||
|
||||
/**
|
||||
* A attachment attached to a measurement unit element.
|
||||
|
@ -44,13 +45,5 @@ class StorelocationAttachment extends Attachment
|
|||
*/
|
||||
protected $element;
|
||||
|
||||
public function setElement(AttachmentContainingDBElement $element): Attachment
|
||||
{
|
||||
if (!$element instanceof Storelocation) {
|
||||
throw new \InvalidArgumentException('The element associated with a StorelocationAttachment must be a Storelocation!');
|
||||
}
|
||||
|
||||
$this->element = $element;
|
||||
return $this;
|
||||
}
|
||||
public const ALLOWED_ELEMENT_CLASS = Storelocation::class;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue