mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-12 13:19:33 +00:00
Stücklisten beim Löschen: Markieren von referenzierten Baugruppen als Hinweis vornehmen
This commit is contained in:
parent
86b5f7e0ee
commit
2cbfdc6aea
1 changed files with 17 additions and 0 deletions
|
|
@ -24,6 +24,7 @@ namespace App\Controller\AdminPages;
|
|||
|
||||
use App\DataTables\LogDataTable;
|
||||
use App\Entity\AssemblySystem\Assembly;
|
||||
use App\Entity\AssemblySystem\AssemblyBOMEntry;
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Attachments\AttachmentContainingDBElement;
|
||||
use App\Entity\Attachments\AttachmentUpload;
|
||||
|
|
@ -455,6 +456,10 @@ abstract class BaseAdminController extends AbstractController
|
|||
return $this->redirectToRoute($this->route_base.'_edit', ['id' => $entity->getID()]);
|
||||
}
|
||||
} else {
|
||||
if ($entity instanceof Assembly) {
|
||||
$this->markReferencedBomEntry($entity);
|
||||
}
|
||||
|
||||
if ($entity instanceof AbstractStructuralDBElement) {
|
||||
$parent = $entity->getParent();
|
||||
|
||||
|
|
@ -502,4 +507,16 @@ abstract class BaseAdminController extends AbstractController
|
|||
|
||||
return $exporter->exportEntityFromRequest($entity, $request);
|
||||
}
|
||||
|
||||
private function markReferencedBomEntry(Assembly $referencedAssembly): void
|
||||
{
|
||||
$bomEntries = $this->entityManager->getRepository(AssemblyBOMEntry::class)->findBy(['referencedAssembly' => $referencedAssembly]);
|
||||
|
||||
foreach ($bomEntries as $entry) {
|
||||
$entry->setReferencedAssembly(null);
|
||||
$entry->setName($referencedAssembly->getName(). ' DELETED');
|
||||
|
||||
$this->entityManager->persist($entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue