mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
476 lines
12 KiB
PHP
476 lines
12 KiB
PHP
<?php
|
|
|
|
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
|
|
use Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodLinkedWithSocialIssuesEntityInterface;
|
|
use Chill\PersonBundle\Entity\SocialWork\Result;
|
|
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
|
use Chill\PersonBundle\Entity\Person;
|
|
use Chill\MainBundle\Entity\User;
|
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
|
use DateTimeInterface;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
|
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
|
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
/**
|
|
* @ORM\Entity
|
|
* @ORM\Table(name="chill_person_accompanying_period_work")
|
|
* @Serializer\DiscriminatorMap(
|
|
* typeProperty="type",
|
|
* mapping={
|
|
* "accompanying_period_work":AccompanyingPeriodWork::class
|
|
* }
|
|
* )
|
|
*/
|
|
class AccompanyingPeriodWork implements TrackCreationInterface, TrackUpdateInterface
|
|
{
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\GeneratedValue
|
|
* @ORM\Column(type="integer")
|
|
* @Serializer\Groups({"read"})
|
|
*/
|
|
private ?int $id;
|
|
|
|
/**
|
|
* @ORM\Column(type="text")
|
|
* @Serializer\Groups({"read", "accompanying_period_work:edit"})
|
|
*/
|
|
private string $note = "";
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class)
|
|
* @Serializer\Groups({"read"})
|
|
*/
|
|
private ?AccompanyingPeriod $accompanyingPeriod = null;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity=SocialAction::class)
|
|
* @Serializer\Groups({"read"})
|
|
* @Serializer\Groups({"accompanying_period_work:create"})
|
|
*/
|
|
private ?SocialAction $socialAction = null;
|
|
|
|
/**
|
|
* @ORM\Column(type="datetime_immutable")
|
|
* @Serializer\Groups({"read"})
|
|
*/
|
|
private ?\DateTimeImmutable $createdAt = null;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity=User::class)
|
|
* @ORM\JoinColumn(nullable=false)
|
|
* @Serializer\Groups({"read"})
|
|
*/
|
|
private ?User $createdBy = null;
|
|
|
|
/**
|
|
* @ORM\Column(type="datetime_immutable")
|
|
* @Serializer\Groups({"read"})
|
|
*/
|
|
private ?\DateTimeImmutable $updatedAt = null;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity=User::class)
|
|
* @ORM\JoinColumn(nullable=false)
|
|
* @Serializer\Groups({"read"})
|
|
*/
|
|
private ?User $updatedBy = null;
|
|
|
|
/**
|
|
* @ORM\Column(type="date_immutable")
|
|
* @Serializer\Groups({"accompanying_period_work:create"})
|
|
* @Serializer\Groups({"accompanying_period_work:edit"})
|
|
* @Serializer\Groups({"read"})
|
|
*/
|
|
private \DateTimeImmutable $startDate;
|
|
|
|
/**
|
|
* @ORM\Column(type="date_immutable", nullable=true, options={"default":null})
|
|
* @Serializer\Groups({"accompanying_period_work:create"})
|
|
* @Serializer\Groups({"accompanying_period_work:edit"})
|
|
* @Serializer\Groups({"read"})
|
|
* @Assert\GreaterThan(propertyPath="startDate",
|
|
* message="accompanying_course_work.The endDate should be greater than the start date"
|
|
* )
|
|
*/
|
|
private ?\DateTimeImmutable $endDate = null;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
|
|
* @Serializer\Groups({"read"})
|
|
* @Serializer\Groups({"accompanying_period_work:edit"})
|
|
*
|
|
* In schema : traitant
|
|
*/
|
|
private ?ThirdParty $handlingThierParty = null;
|
|
|
|
/**
|
|
* @ORM\Column(type="boolean")
|
|
*/
|
|
private bool $createdAutomatically = false;
|
|
|
|
/**
|
|
* @ORM\Column(type="text")
|
|
*/
|
|
private string $createdAutomaticallyReason = "";
|
|
|
|
/**
|
|
* @ORM\OneToMany(
|
|
* targetEntity=AccompanyingPeriodWorkGoal::class,
|
|
* mappedBy="accompanyingPeriodWork",
|
|
* cascade={"persist"},
|
|
* orphanRemoval=true
|
|
* )
|
|
* @Serializer\Groups({"read"})
|
|
* @Serializer\Groups({"accompanying_period_work:edit"})
|
|
*/
|
|
private Collection $goals;
|
|
|
|
/**
|
|
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorks")
|
|
* @ORM\JoinTable(name="chill_person_accompanying_period_work_result")
|
|
* @Serializer\Groups({"read"})
|
|
* @Serializer\Groups({"accompanying_period_work:edit"})
|
|
*/
|
|
private Collection $results;
|
|
|
|
/**
|
|
* @ORM\ManyToMany(targetEntity=ThirdParty::class)
|
|
* @ORM\JoinTable(name="chill_person_accompanying_period_work_third_party")
|
|
*
|
|
* In schema : intervenants
|
|
* @Serializer\Groups({"read"})
|
|
* @Serializer\Groups({"accompanying_period_work:edit"})
|
|
*/
|
|
private Collection $thirdParties;
|
|
|
|
/**
|
|
*
|
|
* @ORM\ManyToMany(targetEntity=Person::class)
|
|
* @ORM\JoinTable(name="chill_person_accompanying_period_work_person")
|
|
* @Serializer\Groups({"read"})
|
|
* @Serializer\Groups({"accompanying_period_work:edit"})
|
|
* @Serializer\Groups({"accompanying_period_work:create"})
|
|
*/
|
|
private Collection $persons;
|
|
|
|
/**
|
|
* @var Collection
|
|
* @ORM\OneToMany(
|
|
* targetEntity=AccompanyingPeriodWorkEvaluation::class,
|
|
* mappedBy="accompanyingPeriodWork",
|
|
* cascade={"remove", "persist"},
|
|
* orphanRemoval=true
|
|
* )
|
|
* @Serializer\Groups({"read"})
|
|
* @internal /!\ the serialization for write evaluations is handled in `AccompanyingPeriodWorkDenormalizer`
|
|
*/
|
|
private Collection $accompanyingPeriodWorkEvaluations;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->goals = new ArrayCollection();
|
|
$this->results = new ArrayCollection();
|
|
$this->thirdParties = new ArrayCollection();
|
|
$this->persons = new ArrayCollection();
|
|
$this->accompanyingPeriodWorkEvaluations = new ArrayCollection();
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getNote(): ?string
|
|
{
|
|
return $this->note;
|
|
}
|
|
|
|
public function setNote(string $note): self
|
|
{
|
|
$this->note = $note;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getAccompanyingPeriod(): ?AccompanyingPeriod
|
|
{
|
|
return $this->accompanyingPeriod;
|
|
}
|
|
|
|
/**
|
|
* Internal: you should use `$accompanyingPeriod->removeWork($work);` or
|
|
* `$accompanyingPeriod->addWork($work);`
|
|
*/
|
|
public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self
|
|
{
|
|
if ($this->accompanyingPeriod instanceof AccompanyingPeriod &&
|
|
$accompanyingPeriod !== $this->accompanyingPeriod) {
|
|
throw new \LogicException("A work cannot change accompanyingPeriod");
|
|
}
|
|
|
|
$this->accompanyingPeriod = $accompanyingPeriod;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getSocialAction(): ?SocialAction
|
|
{
|
|
return $this->socialAction;
|
|
}
|
|
|
|
public function setSocialAction(?SocialAction $socialAction): self
|
|
{
|
|
$this->socialAction = $socialAction;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCreatedAt(): ?\DateTimeImmutable
|
|
{
|
|
return $this->createdAt;
|
|
}
|
|
|
|
public function setCreatedAt(\DateTimeInterface $createdAt): self
|
|
{
|
|
$this->createdAt = $createdAt;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCreatedBy(): ?User
|
|
{
|
|
return $this->createdBy;
|
|
}
|
|
|
|
public function setCreatedBy(?User $createdBy): self
|
|
{
|
|
$this->createdBy = $createdBy;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setUpdatedBy(User $user): TrackUpdateInterface
|
|
{
|
|
$this->updatedBy = $user;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setUpdatedAt(DateTimeInterface $datetime): TrackUpdateInterface
|
|
{
|
|
$this->updatedAt = $datetime;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getUpdatedAt(): ?\DateTimeImmutable
|
|
{
|
|
return $this->updatedAt;
|
|
}
|
|
|
|
public function getUpdatedBy(): ?User
|
|
{
|
|
return $this->updatedBy;
|
|
}
|
|
|
|
public function getStartDate(): ?\DateTimeInterface
|
|
{
|
|
return $this->startDate;
|
|
}
|
|
|
|
public function setStartDate(\DateTimeInterface $startDate): self
|
|
{
|
|
$this->startDate = $startDate;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getEndDate(): ?\DateTimeInterface
|
|
{
|
|
return $this->endDate;
|
|
}
|
|
|
|
public function setEndDate(?\DateTimeInterface $endDate = null): self
|
|
{
|
|
$this->endDate = $endDate;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getHandlingThierParty(): ?ThirdParty
|
|
{
|
|
return $this->handlingThierParty;
|
|
}
|
|
|
|
public function setHandlingThierParty(?ThirdParty $handlingThierParty): self
|
|
{
|
|
$this->handlingThierParty = $handlingThierParty;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCreatedAutomatically(): ?bool
|
|
{
|
|
return $this->createdAutomatically;
|
|
}
|
|
|
|
public function setCreatedAutomatically(bool $createdAutomatically): self
|
|
{
|
|
$this->createdAutomatically = $createdAutomatically;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCreatedAutomaticallyReason(): ?string
|
|
{
|
|
return $this->createdAutomaticallyReason;
|
|
}
|
|
|
|
public function setCreatedAutomaticallyReason(string $createdAutomaticallyReason): self
|
|
{
|
|
$this->createdAutomaticallyReason = $createdAutomaticallyReason;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection|AccompanyingPeriodWorkGoal[]
|
|
*/
|
|
public function getGoals(): Collection
|
|
{
|
|
return $this->goals;
|
|
}
|
|
|
|
public function addGoal(AccompanyingPeriodWorkGoal $goal): self
|
|
{
|
|
if (!$this->goals->contains($goal)) {
|
|
$this->goals[] = $goal;
|
|
$goal->setAccompanyingPeriodWork($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeGoal(AccompanyingPeriodWorkGoal $goal): self
|
|
{
|
|
if ($this->goals->removeElement($goal)) {
|
|
// set the owning side to null (unless already changed)
|
|
if ($goal->getAccompanyingPeriodWork() === $this) {
|
|
$goal->setAccompanyingPeriodWork(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection|Result[]
|
|
*/
|
|
public function getResults(): Collection
|
|
{
|
|
return $this->results;
|
|
}
|
|
|
|
public function addResult(Result $result): self
|
|
{
|
|
if (!$this->results->contains($result)) {
|
|
$this->results[] = $result;
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeResult(Result $result): self
|
|
{
|
|
$this->results->removeElement($result);
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection|ThirdParty[]
|
|
*/
|
|
public function getThirdParties(): Collection
|
|
{
|
|
return $this->thirdParties;
|
|
}
|
|
|
|
public function getThirdPartys(): Collection
|
|
{
|
|
return $this->getThirdParties();
|
|
}
|
|
|
|
public function addThirdParty(ThirdParty $thirdParty): self
|
|
{
|
|
if (!$this->thirdParties->contains($thirdParty)) {
|
|
$this->thirdParties[] = $thirdParty;
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeThirdParty(ThirdParty $thirdParty): self
|
|
{
|
|
$this->thirdParties->removeElement($thirdParty);
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getPersons(): Collection
|
|
{
|
|
return $this->persons;
|
|
}
|
|
|
|
public function addPerson(Person $person): self
|
|
{
|
|
if (!$this->persons->contains($person)) {
|
|
$this->persons[] = $person;
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removePerson(Person $person): self
|
|
{
|
|
$this->persons->removeElement($person);
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection
|
|
*/
|
|
public function getAccompanyingPeriodWorkEvaluations()
|
|
{
|
|
return $this->accompanyingPeriodWorkEvaluations;
|
|
}
|
|
|
|
public function addAccompanyingPeriodWorkEvaluation(AccompanyingPeriodWorkEvaluation $evaluation): self
|
|
{
|
|
if (!$this->accompanyingPeriodWorkEvaluations->contains($evaluation)) {
|
|
$this->accompanyingPeriodWorkEvaluations[] = $evaluation;
|
|
$evaluation->setAccompanyingPeriodWork($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeAccompanyingPeriodWorkEvaluation(AccompanyingPeriodWorkEvaluation $evaluation): self
|
|
{
|
|
$this->accompanyingPeriodWorkEvaluations
|
|
->removeElement($evaluation);
|
|
$evaluation->setAccompanyingPeriodWork(null);
|
|
|
|
return $this;
|
|
}
|
|
}
|