chore: refactor feedback entity instantiation
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20240110122028 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE feedback CHANGE destination_name destination_name VARCHAR(255) DEFAULT NULL, CHANGE assignment_date assignment_date DATE DEFAULT NULL COMMENT \'(DC2Type:date_immutable)\', CHANGE job_profile_name job_profile_name VARCHAR(255) DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE feedback CHANGE destination_name destination_name VARCHAR(255) NOT NULL, CHANGE job_profile_name job_profile_name VARCHAR(255) NOT NULL, CHANGE assignment_date assignment_date DATE NOT NULL COMMENT \'(DC2Type:date_immutable)\'');
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ class ProvideController extends AbstractController
|
||||
->getFeedbackSet()
|
||||
;
|
||||
|
||||
$feedback = new Feedback($assignment, $user);
|
||||
$feedback = Feedback::fromAssignment($assignment, $user);
|
||||
|
||||
$form = $this->createForm(FeedbackType::class, $feedback, ['feedback_set' => $feedbackSet]);
|
||||
$form->handleRequest($request);
|
||||
|
||||
+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