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()
|
->getFeedbackSet()
|
||||||
;
|
;
|
||||||
|
|
||||||
$feedback = new Feedback($assignment, $user);
|
$feedback = Feedback::fromAssignment($assignment, $user);
|
||||||
|
|
||||||
$form = $this->createForm(FeedbackType::class, $feedback, ['feedback_set' => $feedbackSet]);
|
$form = $this->createForm(FeedbackType::class, $feedback, ['feedback_set' => $feedbackSet]);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|||||||
+21
-23
@@ -34,14 +34,14 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface
|
|||||||
#[ORM\ManyToOne(inversedBy: 'feedback')]
|
#[ORM\ManyToOne(inversedBy: 'feedback')]
|
||||||
private ?Teamer $teamer = null;
|
private ?Teamer $teamer = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
private ?string $destinationName;
|
private ?string $destinationName = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
private ?string $jobProfileName;
|
private ?string $jobProfileName = null;
|
||||||
|
|
||||||
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
|
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
|
||||||
private ?\DateTimeImmutable $assignmentDate;
|
private ?\DateTimeImmutable $assignmentDate = null;
|
||||||
|
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
#[Assert\Count(min: 1, minMessage: 'Bitte gib eine Bewertung ab')]
|
#[Assert\Count(min: 1, minMessage: 'Bitte gib eine Bewertung ab')]
|
||||||
@@ -57,17 +57,27 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface
|
|||||||
private ?string $commentInternal = null;
|
private ?string $commentInternal = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
#[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->uuid = Uuid::v4();
|
||||||
$this->destinationName = $assignment->getDestination()->getProduct();
|
|
||||||
$this->assignmentDate = $assignment->getEffectiveDateFrom();
|
|
||||||
$this->jobProfileName = $assignment->getJobProfile()->getName();
|
|
||||||
$this->author = $author->getFullName();
|
$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
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
@@ -102,18 +112,6 @@ class Feedback implements BlameableEntityInterface, TimestampableEntityInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDestination(): ?Destination
|
|
||||||
{
|
|
||||||
return $this->destination;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDestination(?Destination $destination): static
|
|
||||||
{
|
|
||||||
$this->destination = $destination;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDestinationName(): ?string
|
public function getDestinationName(): ?string
|
||||||
{
|
{
|
||||||
return $this->destinationName;
|
return $this->destinationName;
|
||||||
|
|||||||
Reference in New Issue
Block a user