mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-04 20:39:40 +00:00
Add capability to store closing motive when closing accompanying period
The commit introduces new functionality in the bundle that allows storing the closing motive when a course is closed. This is achieved by modifying the model and database schema to include a new `closingMotive` field in AccompanyingPeriodStepHistory entity.
This commit is contained in:
@@ -1449,7 +1449,7 @@ class AccompanyingPeriod implements
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setStep(string $step): self
|
||||
public function setStep(string $step, array $context = []): self
|
||||
{
|
||||
$previous = $this->step;
|
||||
|
||||
@@ -1464,7 +1464,7 @@ class AccompanyingPeriod implements
|
||||
$history = new AccompanyingPeriodStepHistory();
|
||||
$history->setStep($this->step)->setStartDate(new \DateTimeImmutable('now'));
|
||||
|
||||
$this->addStepHistory($history);
|
||||
$this->addStepHistory($history, $context);
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -1507,11 +1507,14 @@ class AccompanyingPeriod implements
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function addStepHistory(AccompanyingPeriodStepHistory $stepHistory): self
|
||||
private function addStepHistory(AccompanyingPeriodStepHistory $stepHistory, array $context = []): self
|
||||
{
|
||||
if (!$this->stepHistories->contains($stepHistory)) {
|
||||
$this->stepHistories[] = $stepHistory;
|
||||
$stepHistory->setPeriod($this);
|
||||
if (($context['closing_motive'] ?? null) instanceof ClosingMotive) {
|
||||
$stepHistory->setClosingMotive($context['closing_motive']);
|
||||
}
|
||||
$this->ensureStepContinuity();
|
||||
}
|
||||
|
||||
|
@@ -59,6 +59,13 @@ class AccompanyingPeriodStepHistory implements TrackCreationInterface, TrackUpda
|
||||
*/
|
||||
private string $step;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=ClosingMotive::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
private ?AccompanyingPeriod\ClosingMotive $closingMotive = null;
|
||||
|
||||
public function getEndDate(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->endDate;
|
||||
@@ -114,4 +121,16 @@ class AccompanyingPeriodStepHistory implements TrackCreationInterface, TrackUpda
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getClosingMotive(): ?AccompanyingPeriod\ClosingMotive
|
||||
{
|
||||
return $this->closingMotive;
|
||||
}
|
||||
|
||||
public function setClosingMotive(?AccompanyingPeriod\ClosingMotive $closingMotive): self
|
||||
{
|
||||
$this->closingMotive = $closingMotive;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user