mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 18:58:46 +02:00
parent
34760a068c
commit
4f70e9fe5a
1 changed files with 7 additions and 1 deletions
|
@ -44,6 +44,7 @@ namespace App\Validator\Constraints;
|
||||||
|
|
||||||
use App\Entity\Parts\PartLot;
|
use App\Entity\Parts\PartLot;
|
||||||
use App\Entity\Parts\Storelocation;
|
use App\Entity\Parts\Storelocation;
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Constraint;
|
||||||
|
@ -77,7 +78,12 @@ class ValidPartLotValidator extends ConstraintValidator
|
||||||
//We can only validate the values if we know the storelocation
|
//We can only validate the values if we know the storelocation
|
||||||
if ($value->getStorageLocation()) {
|
if ($value->getStorageLocation()) {
|
||||||
$repo = $this->em->getRepository(Storelocation::class);
|
$repo = $this->em->getRepository(Storelocation::class);
|
||||||
$parts = $repo->getParts($value);
|
//We can only determine associated parts, if the part have an ID
|
||||||
|
if ($value->getID() !== null) {
|
||||||
|
$parts = new ArrayCollection($repo->getParts($value));
|
||||||
|
} else {
|
||||||
|
$parts = new ArrayCollection([]);
|
||||||
|
}
|
||||||
|
|
||||||
//Check for isFull() attribute
|
//Check for isFull() attribute
|
||||||
if ($value->getStorageLocation()->isFull()) {
|
if ($value->getStorageLocation()->isFull()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue