Allow to automatically map categories from info providers to local categories using the "alternative names" system

This partially addresses issues discussed in discussion #808
This commit is contained in:
Jan Böhmer 2024-12-31 18:31:20 +01:00
parent c9e519d0b5
commit 63893ffabe

View file

@ -27,6 +27,7 @@ use App\Entity\Attachments\AttachmentType;
use App\Entity\Attachments\PartAttachment;
use App\Entity\Base\AbstractStructuralDBElement;
use App\Entity\Parameters\PartParameter;
use App\Entity\Parts\Category;
use App\Entity\Parts\Footprint;
use App\Entity\Parts\InfoProviderReference;
use App\Entity\Parts\Manufacturer;
@ -156,6 +157,9 @@ final class DTOtoEntityConverter
$entity->setMass($dto->mass);
//Try to map the category to an existing entity (but never create a new one)
$entity->setCategory($this->em->getRepository(Category::class)->findForInfoProvider($dto->category));
$entity->setManufacturer($this->getOrCreateEntity(Manufacturer::class, $dto->manufacturer));
$entity->setFootprint($this->getOrCreateEntity(Footprint::class, $dto->footprint));