mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 10:49:00 +02:00
Ensure that its own project builds part is not added to the project BOM
This commit is contained in:
parent
3a60a9848f
commit
9aa6e714f2
2 changed files with 23 additions and 1 deletions
|
@ -199,7 +199,7 @@ class ProjectBOMEntry extends AbstractDBElement
|
||||||
/**
|
/**
|
||||||
* @Assert\Callback
|
* @Assert\Callback
|
||||||
*/
|
*/
|
||||||
public function validate(ExecutionContextInterface $context, $payload)
|
public function validate(ExecutionContextInterface $context, $payload): void
|
||||||
{
|
{
|
||||||
//Round quantity to whole numbers, if the part is not a decimal part
|
//Round quantity to whole numbers, if the part is not a decimal part
|
||||||
if ($this->part) {
|
if ($this->part) {
|
||||||
|
@ -230,6 +230,22 @@ class ProjectBOMEntry extends AbstractDBElement
|
||||||
->atPath('mountnames')
|
->atPath('mountnames')
|
||||||
->addViolation();
|
->addViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Check that the part is not the build representation part of this device or one of its parents
|
||||||
|
if ($this->part && $this->part->getBuiltProject() !== null) {
|
||||||
|
//Get the associated project
|
||||||
|
$associated_project = $this->part->getBuiltProject();
|
||||||
|
//Check that it is not the same as the current project neither one of its parents
|
||||||
|
$current_project = $this->project;
|
||||||
|
while ($current_project) {
|
||||||
|
if ($associated_project === $current_project) {
|
||||||
|
$context->buildViolation('project.bom_entry.can_not_add_own_builds_part')
|
||||||
|
->atPath('part')
|
||||||
|
->addViolation();
|
||||||
|
}
|
||||||
|
$current_project = $current_project->getParent();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -263,5 +263,11 @@
|
||||||
<target>The number of mountnames has to match the BOMs quantity!</target>
|
<target>The number of mountnames has to match the BOMs quantity!</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
|
<unit id="x47D5WT" name="project.bom_entry.can_not_add_own_builds_part">
|
||||||
|
<segment>
|
||||||
|
<source>project.bom_entry.can_not_add_own_builds_part</source>
|
||||||
|
<target>You can not add a project's own builds part to the BOM.</target>
|
||||||
|
</segment>
|
||||||
|
</unit>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue