mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-14 06:09:33 +00:00
JSON Importer mit Minimaldaten weiterentwickeln. Validierung mit Violations einführen und beim Import-Versuch zusätzlich mit ausgeben
This commit is contained in:
parent
de80b5e21e
commit
33925b9d59
16 changed files with 979 additions and 95 deletions
60
src/Services/ImportExportSystem/ImporterResult.php
Normal file
60
src/Services/ImportExportSystem/ImporterResult.php
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Services\ImportExportSystem;
|
||||
|
||||
use Symfony\Component\Validator\ConstraintViolation;
|
||||
use Symfony\Component\Validator\ConstraintViolationList;
|
||||
|
||||
class ImporterResult
|
||||
{
|
||||
private array $bomEntries = [];
|
||||
private ConstraintViolationList $violations;
|
||||
|
||||
public function __construct(array $bomEntries = [])
|
||||
{
|
||||
$this->bomEntries = $bomEntries;
|
||||
$this->violations = new ConstraintViolationList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt einen neuen BOM-Eintrag hinzu.
|
||||
*/
|
||||
public function addBomEntry(object $bomEntry): void
|
||||
{
|
||||
$this->bomEntries[] = $bomEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt alle BOM-Einträge zurück.
|
||||
*/
|
||||
public function getBomEntries(): array
|
||||
{
|
||||
return $this->bomEntries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt die Liste der Violation zurück.
|
||||
*/
|
||||
public function getViolations(): ConstraintViolationList
|
||||
{
|
||||
return $this->violations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt eine neue `ConstraintViolation` zur Liste hinzu.
|
||||
*/
|
||||
public function addViolation(ConstraintViolation $violation): void
|
||||
{
|
||||
$this->violations->add($violation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft, ob die Liste der Violationen leer ist.
|
||||
*/
|
||||
public function hasViolations(): bool
|
||||
{
|
||||
return count($this->violations) > 0;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue