diff --git a/src/DataTables/AssemblyBomEntriesDataTable.php b/src/DataTables/AssemblyBomEntriesDataTable.php index 55a47584..90924cfe 100644 --- a/src/DataTables/AssemblyBomEntriesDataTable.php +++ b/src/DataTables/AssemblyBomEntriesDataTable.php @@ -91,6 +91,8 @@ class AssemblyBomEntriesDataTable implements DataTableTypeInterface return htmlspecialchars((string) $context->getName()); } + $tmp = $context->getName(); + if ($context->getPart() !== null) { $tmp = $this->partDataTableHelper->renderName($context->getPart()); $tmp = $this->translator->trans('part.table.name.value.for_part', ['%value%' => $tmp]); diff --git a/src/DataTables/Filters/AssemblySearchFilter.php b/src/DataTables/Filters/AssemblySearchFilter.php index 1627cc61..2ab33c83 100644 --- a/src/DataTables/Filters/AssemblySearchFilter.php +++ b/src/DataTables/Filters/AssemblySearchFilter.php @@ -135,17 +135,6 @@ class AssemblySearchFilter implements FilterInterface return $this; } - public function isCategory(): bool - { - return $this->category; - } - - public function setCategory(bool $category): AssemblySearchFilter - { - $this->category = $category; - return $this; - } - public function isDescription(): bool { return $this->description; diff --git a/src/Form/AdminPages/AssemblyAdminForm.php b/src/Form/AdminPages/AssemblyAdminForm.php index 2c2f3cc4..dd0a8038 100644 --- a/src/Form/AdminPages/AssemblyAdminForm.php +++ b/src/Form/AdminPages/AssemblyAdminForm.php @@ -37,7 +37,7 @@ class AssemblyAdminForm extends BaseEntityAdminForm public function __construct( protected Security $security, protected EventCommentNeededHelper $eventCommentNeededHelper, - protected AssemblySettings $assemblySettings, + protected ?AssemblySettings $assemblySettings = null, ) { parent::__construct($security, $eventCommentNeededHelper, $assemblySettings); } diff --git a/src/Form/AdminPages/BaseEntityAdminForm.php b/src/Form/AdminPages/BaseEntityAdminForm.php index 5ffd7f4d..35afbaa1 100644 --- a/src/Form/AdminPages/BaseEntityAdminForm.php +++ b/src/Form/AdminPages/BaseEntityAdminForm.php @@ -52,7 +52,7 @@ class BaseEntityAdminForm extends AbstractType public function __construct( protected Security $security, protected EventCommentNeededHelper $eventCommentNeededHelper, - protected AssemblySettings $assemblySettings, + protected ?AssemblySettings $assemblySettings = null, ) { } @@ -74,7 +74,7 @@ class BaseEntityAdminForm extends AbstractType ->add('name', TextType::class, [ 'empty_data' => '', 'label' => 'name.label', - 'data' => $is_new && $entity instanceof Assembly && $this->assemblySettings->useIpnPlaceholderInName ? '%%ipn%%' : $entity->getName(), + 'data' => $is_new && $entity instanceof Assembly && $this->assemblySettings !== null && $this->assemblySettings->useIpnPlaceholderInName ? '%%ipn%%' : $entity->getName(), 'attr' => [ 'placeholder' => 'part.name.placeholder', ], diff --git a/src/Form/Filters/LogFilterType.php b/src/Form/Filters/LogFilterType.php index c973ad0f..4fb5bc49 100644 --- a/src/Form/Filters/LogFilterType.php +++ b/src/Form/Filters/LogFilterType.php @@ -114,6 +114,8 @@ class LogFilterType extends AbstractType LogTargetType::CATEGORY => 'category.label', LogTargetType::PROJECT => 'project.label', LogTargetType::BOM_ENTRY => 'project_bom_entry.label', + LogTargetType::ASSEMBLY => 'assembly.label', + LogTargetType::ASSEMBLY_BOM_ENTRY => 'assembly_bom_entry.label', LogTargetType::FOOTPRINT => 'footprint.label', LogTargetType::GROUP => 'group.label', LogTargetType::MANUFACTURER => 'manufacturer.label', diff --git a/src/Repository/AssemblyRepository.php b/src/Repository/AssemblyRepository.php index 031e6e82..eef36690 100644 --- a/src/Repository/AssemblyRepository.php +++ b/src/Repository/AssemblyRepository.php @@ -45,7 +45,7 @@ use App\Entity\AssemblySystem\Assembly; /** * @template TEntityClass of Assembly - * @extends DBElementRepository + * @extends StructuralDBElementRepository */ class AssemblyRepository extends StructuralDBElementRepository { @@ -66,4 +66,4 @@ class AssemblyRepository extends StructuralDBElementRepository return $qb->getQuery()->getResult(); } -} \ No newline at end of file +} diff --git a/src/Services/ImportExportSystem/BOMImporter.php b/src/Services/ImportExportSystem/BOMImporter.php index cf495a89..fc0791ee 100644 --- a/src/Services/ImportExportSystem/BOMImporter.php +++ b/src/Services/ImportExportSystem/BOMImporter.php @@ -513,8 +513,10 @@ class BOMImporter //Convert column name into hierarchy $path = explode('_', $column); + /** @var array $temp */ $temp = &$entry; + /** @var lowercase-string $step */ foreach ($path as $step) { if (!isset($temp[$step])) { $temp[$step] = []; @@ -526,7 +528,7 @@ class BOMImporter //If there is no value, skip if (isset($values[$index]) && $values[$index] !== '') { //Check whether the value is numerical - if (is_numeric($values[$index]) && !in_array($column, ['name','description','manufacturer','designator'])) { + if (is_numeric($values[$index]) && !in_array($column, ['name','description','manufacturer','designator'], true)) { //Convert to integer or float $temp = (str_contains($values[$index], '.')) ? floatval($values[$index]) @@ -577,7 +579,7 @@ class BOMImporter $bomEntry->setMountnames(trim($entry['designator']) === '' ? '' : trim($entry['designator'])); } - $bomEntry->setQuantity((float) $entry['quantity'] ?? 0); + $bomEntry->setQuantity((float) $entry['quantity']); $result->addBomEntry($bomEntry); } @@ -706,7 +708,7 @@ class BOMImporter $result->addViolation($this->buildJsonViolation( 'validator.bom_importer.json_csv.parameter.array', 'entry[$key].part.manufacturer', - $entry['part']['manufacturer']) ?? null + $entry['part']['manufacturer']) ); } @@ -728,8 +730,8 @@ class BOMImporter if (($manufacturerIdValid || $manufacturerNameValid) && $manufacturer === null) { $value = sprintf( 'manufacturer.id: %s, manufacturer.name: %s', - isset($entry['part']['manufacturer']['id']) && $entry['part']['manufacturer']['id'] !== null ? '' . $entry['part']['manufacturer']['id'] . '' : '-', - isset($entry['part']['manufacturer']['name']) && $entry['part']['manufacturer']['name'] !== null ? '' . $entry['part']['manufacturer']['name'] . '' : '-' + isset($entry['part']['manufacturer']['id']) && $entry['part']['manufacturer']['id'] != null ? '' . $entry['part']['manufacturer']['id'] . '' : '-', + isset($entry['part']['manufacturer']['name']) && $entry['part']['manufacturer']['name'] != null ? '' . $entry['part']['manufacturer']['name'] . '' : '-' ); $result->addViolation($this->buildJsonViolation( @@ -760,7 +762,7 @@ class BOMImporter $result->addViolation($this->buildJsonViolation( 'validator.bom_importer.json_csv.parameter.array', 'entry[$key].part.category', - $entry['part']['category']) ?? null + $entry['part']['category']) ); } @@ -782,8 +784,8 @@ class BOMImporter if (($categoryIdValid || $categoryNameValid)) { $value = sprintf( 'category.id: %s, category.name: %s', - isset($entry['part']['category']['id']) && $entry['part']['category']['id'] !== null ? '' . $entry['part']['category']['id'] . '' : '-', - isset($entry['part']['category']['name']) && $entry['part']['category']['name'] !== null ? '' . $entry['part']['category']['name'] . '' : '-' + isset($entry['part']['category']['id']) && $entry['part']['category']['id'] != null ? '' . $entry['part']['category']['id'] . '' : '-', + isset($entry['part']['category']['name']) && $entry['part']['category']['name'] != null ? '' . $entry['part']['category']['name'] . '' : '-' ); $result->addViolation($this->buildJsonViolation( @@ -816,11 +818,13 @@ class BOMImporter $part->setDescription($partDescription); } + /** @var Manufacturer|null $manufacturer */ if ($manufacturer !== null && $manufacturer->getID() !== $part->getManufacturer()->getID()) { //When updating the associated parts, take over to a assembly of the manufacturer of the part. $part->setManufacturer($manufacturer); } + /** @var Category|null $category */ if ($category !== null && $category->getID() !== $part->getCategory()->getID()) { //When updating the associated parts to a assembly, take over the category of the part. $part->setCategory($category); diff --git a/src/Services/ImportExportSystem/EntityExporter.php b/src/Services/ImportExportSystem/EntityExporter.php index 7db3f5eb..028a537e 100644 --- a/src/Services/ImportExportSystem/EntityExporter.php +++ b/src/Services/ImportExportSystem/EntityExporter.php @@ -414,7 +414,7 @@ class EntityExporter 'ProjectFullName' => $this->getFullName($entity), //BOM relevant attributes - 'Quantity' => $bomEntry->getQuantity() ?? '', + 'Quantity' => $bomEntry->getQuantity(), 'PartId' => $bomEntry->getPart()?->getId() ?? '', 'PartName' => $bomEntry->getPart()?->getName() ?? '', 'Ipn' => $bomEntry->getPart()?->getIpn() ?? '', @@ -582,7 +582,7 @@ class EntityExporter 'AssemblyFullName' => $this->getFullName($assembly), //BOM relevant attributes - 'Quantity' => $bomEntry->getQuantity() ?? '', + 'Quantity' => $bomEntry->getQuantity(), 'PartId' => $bomEntry->getPart()?->getId() ?? '-', 'PartName' => $bomEntry->getPart()?->getName() ?? '-', 'Ipn' => $bomEntry->getPart()?->getIpn() ?? '-', diff --git a/src/Validator/Constraints/AssemblySystem/AssemblyCycleValidator.php b/src/Validator/Constraints/AssemblySystem/AssemblyCycleValidator.php index f12f19a7..c8fd18d3 100644 --- a/src/Validator/Constraints/AssemblySystem/AssemblyCycleValidator.php +++ b/src/Validator/Constraints/AssemblySystem/AssemblyCycleValidator.php @@ -132,10 +132,10 @@ class AssemblyCycleValidator extends ConstraintValidator * The process involves reflection to access private or protected properties of violation objects. * * @param mixed $value The value that triggered the violation. - * @param Constraint $constraint The constraint containing the validation details. + * @param AssemblyCycle $constraint The constraint containing the validation details. * */ - private function addViolation(mixed $value, Constraint $constraint): void + private function addViolation(mixed $value, AssemblyCycle $constraint): void { /** @var ConstraintViolationBuilder $buildViolation */ $buildViolation = $this->context->buildViolation($constraint->message) @@ -166,4 +166,4 @@ class AssemblyCycleValidator extends ConstraintValidator $buildViolation->addViolation(); } } -} \ No newline at end of file +} diff --git a/src/Validator/Constraints/AssemblySystem/AssemblyInvalidBomEntryValidator.php b/src/Validator/Constraints/AssemblySystem/AssemblyInvalidBomEntryValidator.php index 276c865e..e563fa8d 100644 --- a/src/Validator/Constraints/AssemblySystem/AssemblyInvalidBomEntryValidator.php +++ b/src/Validator/Constraints/AssemblySystem/AssemblyInvalidBomEntryValidator.php @@ -97,19 +97,6 @@ class AssemblyInvalidBomEntryValidator extends ConstraintValidator } - private function isOnSameLevel(Assembly $assembly1, Assembly $assembly2): bool - { - $parent1 = $assembly1->getParent(); - $parent2 = $assembly2->getParent(); - - if ($parent1 === null || $parent2 === null) { - return false; - } - - // Beide Assemblies teilen denselben Parent - return $parent1 !== null && $parent2 !== null && $parent1->getId() === $parent2->getId(); - } - /** * Adds a violation to the current context if it hasn’t already been added. * @@ -117,11 +104,11 @@ class AssemblyInvalidBomEntryValidator extends ConstraintValidator * already exists in the context. If such a violation is found, the current violation is not added again. * The process involves reflection to access private or protected properties of violation objects. * - * @param mixed $value The value that triggered the violation. - * @param Constraint $constraint The constraint containing the validation details. + * @param mixed $value The value that triggered the violation. + * @param AssemblyInvalidBomEntry $constraint The constraint containing the validation details. * */ - private function addViolation($value, Constraint $constraint): void + private function addViolation($value, AssemblyInvalidBomEntry $constraint): void { /** @var ConstraintViolationBuilder $buildViolation */ $buildViolation = $this->context->buildViolation($constraint->message) @@ -152,4 +139,4 @@ class AssemblyInvalidBomEntryValidator extends ConstraintValidator $buildViolation->addViolation(); } } -} \ No newline at end of file +} diff --git a/src/Validator/Constraints/AssemblySystem/UniqueReferencedAssemblyValidator.php b/src/Validator/Constraints/AssemblySystem/UniqueReferencedAssemblyValidator.php index 0e58c066..0b3eb395 100644 --- a/src/Validator/Constraints/AssemblySystem/UniqueReferencedAssemblyValidator.php +++ b/src/Validator/Constraints/AssemblySystem/UniqueReferencedAssemblyValidator.php @@ -30,6 +30,7 @@ class UniqueReferencedAssemblyValidator extends ConstraintValidator public function validate($value, Constraint $constraint) { $assemblies = []; + foreach ($value as $entry) { $referencedAssemblyId = $entry->getReferencedAssembly()?->getId(); if ($referencedAssemblyId === null) { @@ -37,6 +38,7 @@ class UniqueReferencedAssemblyValidator extends ConstraintValidator } if (isset($assemblies[$referencedAssemblyId])) { + /** @var UniqueReferencedAssembly $constraint */ $this->context->buildViolation($constraint->message) ->atPath('referencedAssembly') ->addViolation(); @@ -45,4 +47,4 @@ class UniqueReferencedAssemblyValidator extends ConstraintValidator $assemblies[$referencedAssemblyId] = true; } } -} \ No newline at end of file +}