add initial comment to accompanying period

This commit is contained in:
2021-05-18 19:04:09 +02:00
parent d327dae9fa
commit 2610730219
4 changed files with 110 additions and 6 deletions

View File

@@ -122,10 +122,17 @@ class AccompanyingPeriod
* cascade={"persist", "remove"},
* orphanRemoval=true
* )
* @Groups({"read"})
*/
private $comments;
/**
* @ORM\ManyToOne(
* targetEntity=Comment::class
* )
* @Groups({"read"})
*/
private ?Comment $initialComment = null;
/**
* @var Collection
*
@@ -210,21 +217,21 @@ class AccompanyingPeriod
/**
* @var bool
* @ORM\Column(type="boolean")
* @ORM\Column(type="boolean", options={"default": false} )
* @Groups({"read", "write"})
*/
private $requestorAnonymous = false;
/**
* @var bool
* @ORM\Column(type="boolean")
* @ORM\Column(type="boolean", options={"default": false} )
* @Groups({"read", "write"})
*/
private $emergency = false;
/**
* @var bool
* @ORM\Column(type="boolean")
* @ORM\Column(type="boolean", options={"default": false} )
* @Groups({"read", "write"})
*/
private $confidential = false;
@@ -264,6 +271,7 @@ class AccompanyingPeriod
$this->participations = new ArrayCollection();
$this->scopes = new ArrayCollection();
$this->socialIssues = new ArrayCollection();
$this->comments = new ArrayCollection();
}
/**
@@ -357,9 +365,14 @@ class AccompanyingPeriod
return $this->remark;
}
/**
* @Groups({"read"})
*/
public function getComments(): Collection
{
return $this->comments;
return $this->comments->filter(function (Comment $c) {
return $c !== $this->initialComment;
});
}
public function addComment(Comment $comment): self
@@ -376,6 +389,30 @@ class AccompanyingPeriod
$this->comments->removeElement($comment);
}
/**
* @Groups({"write"})
*/
public function setInitialComment(?Comment $comment = null): self
{
if (NULL === $comment && NULL !== $this->initialComment) {
$this->removeComment($this->initialComment);
} elseif ($comment instanceof Comment) {
$this->addComment($comment);
}
$this->initialComment = $comment;
return $this;
}
/**
* @Groups({"read"})
*/
public function getInitialComment(): ?Comment
{
return $this->initialComment;
}
/**
* Get Participations Collection
*/