chore: refactor feedback entity instantiation
This commit is contained in:
+21
-23
@@ -34,14 +34,14 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface
|
||||
#[ORM\ManyToOne(inversedBy: 'feedback')]
|
||||
private ?Teamer $teamer = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $destinationName;
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $destinationName = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $jobProfileName;
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $jobProfileName = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
|
||||
private ?\DateTimeImmutable $assignmentDate;
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
|
||||
private ?\DateTimeImmutable $assignmentDate = null;
|
||||
|
||||
#[ORM\Column]
|
||||
#[Assert\Count(min: 1, minMessage: 'Bitte gib eine Bewertung ab')]
|
||||
@@ -57,17 +57,27 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface
|
||||
private ?string $commentInternal = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $author = null;
|
||||
private ?string $author;
|
||||
|
||||
public function __construct(Assignment $assignment, User $author)
|
||||
public function __construct(User $author)
|
||||
{
|
||||
$this->uuid = Uuid::v4();
|
||||
$this->destinationName = $assignment->getDestination()->getProduct();
|
||||
$this->assignmentDate = $assignment->getEffectiveDateFrom();
|
||||
$this->jobProfileName = $assignment->getJobProfile()->getName();
|
||||
$this->author = $author->getFullName();
|
||||
}
|
||||
|
||||
public static function fromAssignment(Assignment $assignment, User $user): static
|
||||
{
|
||||
$instance = new static($user);
|
||||
|
||||
$instance
|
||||
->setDestinationName($assignment->getDestination()->getProduct())
|
||||
->setAssignmentDate($assignment->getEffectiveDateFrom())
|
||||
->setJobProfileName($assignment->getJobProfile()->getName())
|
||||
;
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@@ -102,18 +112,6 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDestination(): ?Destination
|
||||
{
|
||||
return $this->destination;
|
||||
}
|
||||
|
||||
public function setDestination(?Destination $destination): static
|
||||
{
|
||||
$this->destination = $destination;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDestinationName(): ?string
|
||||
{
|
||||
return $this->destinationName;
|
||||
|
||||
Reference in New Issue
Block a user