mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-23 02:09:03 +02:00
Added possibility to associate a part with a project that represents the builds of the project
This commit is contained in:
parent
adc070d10c
commit
fdcd1b9d9d
6 changed files with 106 additions and 10 deletions
34
src/Services/ProjectSystem/ProjectBuildPartHelper.php
Normal file
34
src/Services/ProjectSystem/ProjectBuildPartHelper.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services\ProjectSystem;
|
||||
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Entity\ProjectSystem\Project;
|
||||
|
||||
class ProjectBuildPartHelper
|
||||
{
|
||||
/**
|
||||
* Returns a part that represents the builds of a project. This part is not saved to the database, and can be used
|
||||
* as initial data for the new part form.
|
||||
* @param Project $project
|
||||
* @return Part
|
||||
*/
|
||||
public function getPartInitialization(Project $project): Part
|
||||
{
|
||||
$part = new Part();
|
||||
|
||||
//Associate the part with the project
|
||||
$part->setBuiltProject($project);
|
||||
|
||||
//Set the name of the part to the name of the project
|
||||
$part->setName($project->getName());
|
||||
|
||||
//Set the description of the part to the description of the project
|
||||
$part->setDescription($project->getDescription());
|
||||
|
||||
//Add a tag to the part that indicates that it is a build part
|
||||
$part->setTags('project-build');
|
||||
|
||||
return $part;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue