mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,169 +1,50 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
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\Doctrine\Model\TrackCreationInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\SocialWork\Result;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use LogicException;
|
||||
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
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
/**
|
||||
* @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;
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class)
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?AccompanyingPeriod $accompanyingPeriod = null;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=AccompanyingPeriodWorkEvaluation::class,
|
||||
* mappedBy="accompanyingPeriodWork",
|
||||
@@ -171,287 +52,142 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||
* 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;
|
||||
}
|
||||
private Collection $accompanyingPeriodWorkEvaluations;
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
* @ORM\Column(type="datetime_immutable")
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
public function getAccompanyingPeriodWorkEvaluations()
|
||||
private ?DateTimeImmutable $createdAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private bool $createdAutomatically = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text")
|
||||
*/
|
||||
private string $createdAutomaticallyReason = '';
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?User $createdBy = null;
|
||||
|
||||
/**
|
||||
* @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\OneToMany(
|
||||
* targetEntity=AccompanyingPeriodWorkGoal::class,
|
||||
* mappedBy="accompanyingPeriodWork",
|
||||
* cascade={"persist"},
|
||||
* orphanRemoval=true
|
||||
* )
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
||||
*/
|
||||
private Collection $goals;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
||||
*
|
||||
* In schema : traitant
|
||||
*/
|
||||
private ?ThirdParty $handlingThierParty = null;
|
||||
|
||||
/**
|
||||
* @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\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;
|
||||
|
||||
/**
|
||||
* @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\ManyToOne(targetEntity=SocialAction::class)
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"accompanying_period_work:create"})
|
||||
*/
|
||||
private ?SocialAction $socialAction = 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\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\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;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
return $this->accompanyingPeriodWorkEvaluations;
|
||||
$this->goals = new ArrayCollection();
|
||||
$this->results = new ArrayCollection();
|
||||
$this->thirdParties = new ArrayCollection();
|
||||
$this->persons = new ArrayCollection();
|
||||
$this->accompanyingPeriodWorkEvaluations = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function addAccompanyingPeriodWorkEvaluation(AccompanyingPeriodWorkEvaluation $evaluation): self
|
||||
@@ -464,6 +200,150 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addGoal(AccompanyingPeriodWorkGoal $goal): self
|
||||
{
|
||||
if (!$this->goals->contains($goal)) {
|
||||
$this->goals[] = $goal;
|
||||
$goal->setAccompanyingPeriodWork($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addPerson(Person $person): self
|
||||
{
|
||||
if (!$this->persons->contains($person)) {
|
||||
$this->persons[] = $person;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addResult(Result $result): self
|
||||
{
|
||||
if (!$this->results->contains($result)) {
|
||||
$this->results[] = $result;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addThirdParty(ThirdParty $thirdParty): self
|
||||
{
|
||||
if (!$this->thirdParties->contains($thirdParty)) {
|
||||
$this->thirdParties[] = $thirdParty;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAccompanyingPeriod(): ?AccompanyingPeriod
|
||||
{
|
||||
return $this->accompanyingPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAccompanyingPeriodWorkEvaluations()
|
||||
{
|
||||
return $this->accompanyingPeriodWorkEvaluations;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function getCreatedAutomatically(): ?bool
|
||||
{
|
||||
return $this->createdAutomatically;
|
||||
}
|
||||
|
||||
public function getCreatedAutomaticallyReason(): ?string
|
||||
{
|
||||
return $this->createdAutomaticallyReason;
|
||||
}
|
||||
|
||||
public function getCreatedBy(): ?User
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
public function getEndDate(): ?DateTimeInterface
|
||||
{
|
||||
return $this->endDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AccompanyingPeriodWorkGoal[]|Collection
|
||||
*/
|
||||
public function getGoals(): Collection
|
||||
{
|
||||
return $this->goals;
|
||||
}
|
||||
|
||||
public function getHandlingThierParty(): ?ThirdParty
|
||||
{
|
||||
return $this->handlingThierParty;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getNote(): ?string
|
||||
{
|
||||
return $this->note;
|
||||
}
|
||||
|
||||
public function getPersons(): Collection
|
||||
{
|
||||
return $this->persons;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Result[]
|
||||
*/
|
||||
public function getResults(): Collection
|
||||
{
|
||||
return $this->results;
|
||||
}
|
||||
|
||||
public function getSocialAction(): ?SocialAction
|
||||
{
|
||||
return $this->socialAction;
|
||||
}
|
||||
|
||||
public function getStartDate(): ?DateTimeInterface
|
||||
{
|
||||
return $this->startDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|ThirdParty[]
|
||||
*/
|
||||
public function getThirdParties(): Collection
|
||||
{
|
||||
return $this->thirdParties;
|
||||
}
|
||||
|
||||
public function getThirdPartys(): Collection
|
||||
{
|
||||
return $this->getThirdParties();
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
public function getUpdatedBy(): ?User
|
||||
{
|
||||
return $this->updatedBy;
|
||||
}
|
||||
|
||||
public function removeAccompanyingPeriodWorkEvaluation(AccompanyingPeriodWorkEvaluation $evaluation): self
|
||||
{
|
||||
$this->accompanyingPeriodWorkEvaluations
|
||||
@@ -472,4 +352,130 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function removePerson(Person $person): self
|
||||
{
|
||||
$this->persons->removeElement($person);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeResult(Result $result): self
|
||||
{
|
||||
$this->results->removeElement($result);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeThirdParty(ThirdParty $thirdParty): self
|
||||
{
|
||||
$this->thirdParties->removeElement($thirdParty);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 setCreatedAt(DateTimeInterface $createdAt): self
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCreatedAutomatically(bool $createdAutomatically): self
|
||||
{
|
||||
$this->createdAutomatically = $createdAutomatically;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCreatedAutomaticallyReason(string $createdAutomaticallyReason): self
|
||||
{
|
||||
$this->createdAutomaticallyReason = $createdAutomaticallyReason;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCreatedBy(?User $createdBy): self
|
||||
{
|
||||
$this->createdBy = $createdBy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setEndDate(?DateTimeInterface $endDate = null): self
|
||||
{
|
||||
$this->endDate = $endDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setHandlingThierParty(?ThirdParty $handlingThierParty): self
|
||||
{
|
||||
$this->handlingThierParty = $handlingThierParty;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setNote(string $note): self
|
||||
{
|
||||
$this->note = $note;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSocialAction(?SocialAction $socialAction): self
|
||||
{
|
||||
$this->socialAction = $socialAction;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setStartDate(DateTimeInterface $startDate): self
|
||||
{
|
||||
$this->startDate = $startDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(DateTimeInterface $datetime): TrackUpdateInterface
|
||||
{
|
||||
$this->updatedAt = $datetime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatedBy(User $user): TrackUpdateInterface
|
||||
{
|
||||
$this->updatedBy = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,36 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use LogicException;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table("chill_person_accompanying_period_work_evaluation")
|
||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "accompanying_period_work_evaluation"=AccompanyingPeriodWorkEvaluation::class,
|
||||
* })
|
||||
* "accompanying_period_work_evaluation": AccompanyingPeriodWorkEvaluation::class,
|
||||
* })
|
||||
*/
|
||||
class AccompanyingPeriodWorkEvaluation implements TrackUpdateInterface, TrackCreationInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=AccompanyingPeriodWork::class,
|
||||
@@ -40,47 +41,6 @@ class AccompanyingPeriodWorkEvaluation implements TrackUpdateInterface, TrackCre
|
||||
private ?AccompanyingPeriodWork $accompanyingPeriodWork = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=Evaluation::class
|
||||
* )
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
private ?Evaluation $evaluation = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"write"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
private ?DateTimeImmutable $startDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"write"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
private ?DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
private ?DateTimeImmutable $maxDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="dateinterval", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"write"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
private ?DateInterval $warningInterval = null;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="text", nullable=false, options={"default": ""})
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"write"})
|
||||
@@ -88,14 +48,6 @@ class AccompanyingPeriodWorkEvaluation implements TrackUpdateInterface, TrackCre
|
||||
*/
|
||||
private string $comment = '';
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=User::class
|
||||
* )
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?User $createdBy = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
@@ -108,25 +60,43 @@ class AccompanyingPeriodWorkEvaluation implements TrackUpdateInterface, TrackCre
|
||||
* )
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?User $updatedBy = null;
|
||||
private ?User $createdBy = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?DateTimeImmutable $updatedAt = null;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=AccompanyingPeriodWorkEvaluationDocument::class,
|
||||
* mappedBy="accompanyingPeriodWorkEvaluation",
|
||||
* cascade={"remove"}
|
||||
* )
|
||||
* )
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private Collection $documents;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"write"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
private ?DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=Evaluation::class
|
||||
* )
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
private ?Evaluation $evaluation = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* This is a workaround for client, to allow them to assign arbitrary data
|
||||
* dedicated to their job.
|
||||
@@ -139,251 +109,51 @@ class AccompanyingPeriodWorkEvaluation implements TrackUpdateInterface, TrackCre
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*
|
||||
* @var mixed
|
||||
*
|
||||
*/
|
||||
private $key = null;
|
||||
private $key;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
private ?DateTimeImmutable $maxDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"write"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
private ?DateTimeImmutable $startDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?DateTimeImmutable $updatedAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=User::class
|
||||
* )
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?User $updatedBy = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="dateinterval", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"write"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
private ?DateInterval $warningInterval = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->documents = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AccompanyingPeriodWork|null
|
||||
*/
|
||||
public function getAccompanyingPeriodWork(): ?AccompanyingPeriodWork
|
||||
{
|
||||
return $this->accompanyingPeriodWork;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccompanyingPeriodWork|null $accompanyingPeriodWork
|
||||
* @return AccompanyingPeriodWorkEvaluation
|
||||
*/
|
||||
public function setAccompanyingPeriodWork(?AccompanyingPeriodWork $accompanyingPeriodWork): AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
if (
|
||||
$accompanyingPeriodWork instanceof AccompanyingPeriodWork
|
||||
&& $this->accompanyingPeriodWork instanceof AccompanyingPeriodWork
|
||||
&& $this->accompanyingPeriodWork->getId() !== $accompanyingPeriodWork->getId()) {
|
||||
throw new \RuntimeException("Changing the ".
|
||||
"accompanyingPeriodWork is not allowed");
|
||||
}
|
||||
|
||||
$this->accompanyingPeriodWork = $accompanyingPeriodWork;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Evaluation|null
|
||||
*/
|
||||
public function getEvaluation(): ?Evaluation
|
||||
{
|
||||
return $this->evaluation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Evaluation|null $evaluation
|
||||
* @return AccompanyingPeriodWorkEvaluation
|
||||
*/
|
||||
public function setEvaluation(?Evaluation $evaluation): AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
if (
|
||||
($evaluation instanceof Evaluation
|
||||
&& $this->evaluation instanceof Evaluation
|
||||
&& $evaluation->getId() !== $this->evaluation->getId())
|
||||
||
|
||||
($this->evaluation instanceof Evaluation
|
||||
&& null === $evaluation)
|
||||
) {
|
||||
$cl = AccompanyingPeriodWorkEvaluation::class;
|
||||
throw new \LogicException("once set, an $cl cannot
|
||||
change or remove the linked Evaluation::class");
|
||||
}
|
||||
|
||||
$this->evaluation = $evaluation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTimeImmutable|null
|
||||
*/
|
||||
public function getStartDate(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->startDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTimeImmutable|null $startDate
|
||||
* @return AccompanyingPeriodWorkEvaluation
|
||||
*/
|
||||
public function setStartDate(?DateTimeImmutable $startDate): AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
$this->startDate = $startDate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTimeImmutable|null
|
||||
*/
|
||||
public function getEndDate(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->endDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTimeImmutable|null $endDate
|
||||
* @return AccompanyingPeriodWorkEvaluation
|
||||
*/
|
||||
public function setEndDate(?DateTimeImmutable $endDate): AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
$this->endDate = $endDate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTimeImmutable|null
|
||||
*/
|
||||
public function getMaxDate(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->maxDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTimeImmutable|null $maxDate
|
||||
* @return AccompanyingPeriodWorkEvaluation
|
||||
*/
|
||||
public function setMaxDate(?DateTimeImmutable $maxDate): AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
$this->maxDate = $maxDate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateInterval|null
|
||||
*/
|
||||
public function getWarningInterval(): ?DateInterval
|
||||
{
|
||||
return $this->warningInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateInterval|null $warningInterval
|
||||
* @return AccompanyingPeriodWorkEvaluation
|
||||
*/
|
||||
public function setWarningInterval(?DateInterval $warningInterval): AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
$this->warningInterval = $warningInterval;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getComment(): string
|
||||
{
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $comment
|
||||
* @return AccompanyingPeriodWorkEvaluation
|
||||
*/
|
||||
public function setComment(string $comment): AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
$this->comment = $comment;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User|null
|
||||
*/
|
||||
public function getCreatedBy(): ?User
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User|null $createdBy
|
||||
* @return AccompanyingPeriodWorkEvaluation
|
||||
*/
|
||||
public function setCreatedBy(?User $createdBy): AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
$this->createdBy = $createdBy;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTimeImmutable|null
|
||||
*/
|
||||
public function getCreatedAt(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTimeImmutable|null $createdAt
|
||||
* @return AccompanyingPeriodWorkEvaluation
|
||||
*/
|
||||
public function setCreatedAt(\DateTimeInterface $createdAt): self
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User|null
|
||||
*/
|
||||
public function getUpdatedBy(): ?User
|
||||
{
|
||||
return $this->updatedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User|null $updatedBy
|
||||
* @return AccompanyingPeriodWorkEvaluation
|
||||
*/
|
||||
public function setUpdatedBy(?User $updatedBy): AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
$this->updatedBy = $updatedBy;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTimeImmutable|null
|
||||
*/
|
||||
public function getUpdatedAt(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTimeImmutable|null $updatedAt
|
||||
* @return AccompanyingPeriodWorkEvaluation
|
||||
*/
|
||||
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getDocuments()
|
||||
{
|
||||
return $this->documents;
|
||||
}
|
||||
|
||||
public function addDocument(AccompanyingPeriodWorkEvaluationDocument $document): self
|
||||
{
|
||||
if (!$this->documents->contains($document)) {
|
||||
@@ -394,14 +164,51 @@ class AccompanyingPeriodWorkEvaluation implements TrackUpdateInterface, TrackCre
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeDocument(AccompanyingPeriodWorkEvaluationDocument $document): self
|
||||
public function getAccompanyingPeriodWork(): ?AccompanyingPeriodWork
|
||||
{
|
||||
$this->documents->removeElement($document);
|
||||
return $this;
|
||||
return $this->accompanyingPeriodWork;
|
||||
}
|
||||
|
||||
public function getComment(): string
|
||||
{
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function getCreatedBy(): ?User
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arbitrary data, used for client
|
||||
* @return Collection
|
||||
*/
|
||||
public function getDocuments()
|
||||
{
|
||||
return $this->documents;
|
||||
}
|
||||
|
||||
public function getEndDate(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->endDate;
|
||||
}
|
||||
|
||||
public function getEvaluation(): ?Evaluation
|
||||
{
|
||||
return $this->evaluation;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arbitrary data, used for client.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -410,10 +217,111 @@ class AccompanyingPeriodWorkEvaluation implements TrackUpdateInterface, TrackCre
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
public function getMaxDate(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->maxDate;
|
||||
}
|
||||
|
||||
public function getStartDate(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->startDate;
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
public function getUpdatedBy(): ?User
|
||||
{
|
||||
return $this->updatedBy;
|
||||
}
|
||||
|
||||
public function getWarningInterval(): ?DateInterval
|
||||
{
|
||||
return $this->warningInterval;
|
||||
}
|
||||
|
||||
public function removeDocument(AccompanyingPeriodWorkEvaluationDocument $document): self
|
||||
{
|
||||
$this->documents->removeElement($document);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setAccompanyingPeriodWork(?AccompanyingPeriodWork $accompanyingPeriodWork): AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
if (
|
||||
$accompanyingPeriodWork instanceof AccompanyingPeriodWork
|
||||
&& $this->accompanyingPeriodWork instanceof AccompanyingPeriodWork
|
||||
&& $this->accompanyingPeriodWork->getId() !== $accompanyingPeriodWork->getId()) {
|
||||
throw new RuntimeException('Changing the ' .
|
||||
'accompanyingPeriodWork is not allowed');
|
||||
}
|
||||
|
||||
$this->accompanyingPeriodWork = $accompanyingPeriodWork;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setComment(string $comment): AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
$this->comment = $comment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arbitrary data, used for client
|
||||
* @param DateTimeImmutable|null $createdAt
|
||||
*
|
||||
* @return AccompanyingPeriodWorkEvaluation
|
||||
*/
|
||||
public function setCreatedAt(DateTimeInterface $createdAt): self
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCreatedBy(?User $createdBy): AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
$this->createdBy = $createdBy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setEndDate(?DateTimeImmutable $endDate): AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
$this->endDate = $endDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setEvaluation(?Evaluation $evaluation): AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
if (
|
||||
($evaluation instanceof Evaluation
|
||||
&& $this->evaluation instanceof Evaluation
|
||||
&& $evaluation->getId() !== $this->evaluation->getId())
|
||||
|| ($this->evaluation instanceof Evaluation
|
||||
&& null === $evaluation)
|
||||
) {
|
||||
$cl = AccompanyingPeriodWorkEvaluation::class;
|
||||
|
||||
throw new LogicException("once set, an {$cl} cannot
|
||||
change or remove the linked Evaluation::class");
|
||||
}
|
||||
|
||||
$this->evaluation = $evaluation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arbitrary data, used for client.
|
||||
*
|
||||
* @param mixed $key
|
||||
*
|
||||
* @return AccompanyingPeriodWorkEvaluation
|
||||
*/
|
||||
public function setKey($key): self
|
||||
@@ -422,4 +330,44 @@ class AccompanyingPeriodWorkEvaluation implements TrackUpdateInterface, TrackCre
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMaxDate(?DateTimeImmutable $maxDate): AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
$this->maxDate = $maxDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setStartDate(?DateTimeImmutable $startDate): AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
$this->startDate = $startDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTimeImmutable|null $updatedAt
|
||||
*
|
||||
* @return AccompanyingPeriodWorkEvaluation
|
||||
*/
|
||||
public function setUpdatedAt(DateTimeInterface $updatedAt): self
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatedBy(?User $updatedBy): AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
$this->updatedBy = $updatedBy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setWarningInterval(?DateInterval $warningInterval): AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
$this->warningInterval = $warningInterval;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
|
||||
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
@@ -7,32 +14,21 @@ use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table("chill_person_accompanying_period_work_evaluation_document")
|
||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "accompanying_period_work_evaluation_document"=AccompanyingPeriodWorkEvaluationDocument::class
|
||||
* })
|
||||
* "accompanying_period_work_evaluation_document": AccompanyingPeriodWorkEvaluationDocument::class
|
||||
* })
|
||||
*/
|
||||
class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doctrine\Model\TrackCreationInterface, \Chill\MainBundle\Doctrine\Model\TrackUpdateInterface
|
||||
{
|
||||
/**
|
||||
* @var int|null
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @internal the default name exceeds 64 characters, we must set manually:
|
||||
* @ORM\SequenceGenerator(sequenceName="chill_person_social_work_eval_doc_id_seq", allocationSize=1, initialValue=1000)
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?int $id;
|
||||
|
||||
/**
|
||||
* @var AccompanyingPeriodWorkEvaluation|null
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=AccompanyingPeriodWorkEvaluation::class,
|
||||
* inversedBy="documents"
|
||||
@@ -40,14 +36,6 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
|
||||
*/
|
||||
private ?AccompanyingPeriodWorkEvaluation $accompanyingPeriodWorkEvaluation = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=User::class
|
||||
* )
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?User $createdBy = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
@@ -60,21 +48,26 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
|
||||
* )
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?User $updatedBy = null;
|
||||
private ?User $createdBy = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @internal the default name exceeds 64 characters, we must set manually:
|
||||
* @ORM\SequenceGenerator(sequenceName="chill_person_social_work_eval_doc_id_seq", allocationSize=1, initialValue=1000)
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?\DateTimeImmutable $updatedAt = null;
|
||||
private ?int $id;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=StoredObject::class,
|
||||
* cascade={"remove"},
|
||||
* )
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=StoredObject::class,
|
||||
* cascade={"remove"},
|
||||
* )
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
*/
|
||||
private ?StoredObject $storedObject = null;
|
||||
|
||||
/**
|
||||
@@ -86,17 +79,65 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
|
||||
private ?DocGeneratorTemplate $template = null;
|
||||
|
||||
/**
|
||||
* @return AccompanyingPeriodWorkEvaluation|null
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?\DateTimeImmutable $updatedAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=User::class
|
||||
* )
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?User $updatedBy = null;
|
||||
|
||||
public function getAccompanyingPeriodWorkEvaluation(): ?AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
return $this->accompanyingPeriodWorkEvaluation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccompanyingPeriodWorkEvaluation|null $accompanyingPeriodWorkEvaluation
|
||||
* @return AccompanyingPeriodWorkEvaluationDocument
|
||||
* @return \DateTimeImmutable|null
|
||||
*/
|
||||
public function getCreatedAt(): ?DateTimeInterface
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function getCreatedBy(): ?User
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getStoredObject(): ?StoredObject
|
||||
{
|
||||
return $this->storedObject;
|
||||
}
|
||||
|
||||
public function getTemplate(): ?DocGeneratorTemplate
|
||||
{
|
||||
return $this->template;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTimeImmutable|null
|
||||
*/
|
||||
public function getUpdatedAt(): ?DateTimeInterface
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
public function getUpdatedBy(): ?User
|
||||
{
|
||||
return $this->updatedBy;
|
||||
}
|
||||
|
||||
public function setAccompanyingPeriodWorkEvaluation(?AccompanyingPeriodWorkEvaluation $accompanyingPeriodWorkEvaluation): AccompanyingPeriodWorkEvaluationDocument
|
||||
{
|
||||
// if an evaluation is already associated, we cannot change the association (removing the association,
|
||||
@@ -104,111 +145,53 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
|
||||
if ($this->accompanyingPeriodWorkEvaluation instanceof AccompanyingPeriodWorkEvaluation
|
||||
&& $accompanyingPeriodWorkEvaluation instanceof AccompanyingPeriodWorkEvaluation) {
|
||||
if ($this->accompanyingPeriodWorkEvaluation !== $accompanyingPeriodWorkEvaluation) {
|
||||
throw new \RuntimeException("It is not allowed to change the evaluation for a document");
|
||||
throw new RuntimeException('It is not allowed to change the evaluation for a document');
|
||||
}
|
||||
}
|
||||
$this->accompanyingPeriodWorkEvaluation = $accompanyingPeriodWorkEvaluation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return StoredObject|null
|
||||
*/
|
||||
public function getStoredObject(): ?StoredObject
|
||||
public function setCreatedAt(DateTimeInterface $datetime): TrackCreationInterface
|
||||
{
|
||||
return $this->storedObject;
|
||||
$this->createdAt = $datetime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCreatedBy(User $user): TrackCreationInterface
|
||||
{
|
||||
$this->createdBy = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param StoredObject|null $storedObject
|
||||
* @return AccompanyingPeriodWorkEvaluationDocument
|
||||
*/
|
||||
public function setStoredObject(?StoredObject $storedObject): AccompanyingPeriodWorkEvaluationDocument
|
||||
{
|
||||
$this->storedObject = $storedObject;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCreatedBy(User $user): \Chill\MainBundle\Doctrine\Model\TrackCreationInterface
|
||||
{
|
||||
$this->createdBy = $user;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCreatedAt(\DateTimeInterface $datetime): \Chill\MainBundle\Doctrine\Model\TrackCreationInterface
|
||||
{
|
||||
$this->createdAt = $datetime;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatedBy(User $user): \Chill\MainBundle\Doctrine\Model\TrackUpdateInterface
|
||||
{
|
||||
$this->updatedBy = $user;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(\DateTimeInterface $datetime): \Chill\MainBundle\Doctrine\Model\TrackUpdateInterface
|
||||
{
|
||||
$this->updatedAt = $datetime;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User|null
|
||||
*/
|
||||
public function getCreatedBy(): ?User
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTimeImmutable|null
|
||||
*/
|
||||
public function getCreatedAt(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User|null
|
||||
*/
|
||||
public function getUpdatedBy(): ?User
|
||||
{
|
||||
return $this->updatedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTimeImmutable|null
|
||||
*/
|
||||
public function getUpdatedAt(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DocGeneratorTemplate|null
|
||||
*/
|
||||
public function getTemplate(): ?DocGeneratorTemplate
|
||||
{
|
||||
return $this->template;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DocGeneratorTemplate|null $template
|
||||
* @return AccompanyingPeriodWorkEvaluationDocument
|
||||
*/
|
||||
public function setTemplate(?DocGeneratorTemplate $template): AccompanyingPeriodWorkEvaluationDocument
|
||||
{
|
||||
$this->template = $template;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(DateTimeInterface $datetime): TrackUpdateInterface
|
||||
{
|
||||
$this->updatedAt = $datetime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatedBy(User $user): TrackUpdateInterface
|
||||
{
|
||||
$this->updatedBy = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
|
||||
use Chill\PersonBundle\Entity\SocialWork\Goal;
|
||||
@@ -7,20 +14,33 @@ use Chill\PersonBundle\Entity\SocialWork\Result;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use LogicException;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_person_accompanying_period_work_goal")
|
||||
* @Serializer\DiscriminatorMap(
|
||||
* typeProperty="type",
|
||||
* mapping={
|
||||
* "accompanying_period_work_goal":AccompanyingPeriodWorkGoal::class
|
||||
* }
|
||||
* )
|
||||
* typeProperty="type",
|
||||
* mapping={
|
||||
* "accompanying_period_work_goal": AccompanyingPeriodWorkGoal::class
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class AccompanyingPeriodWorkGoal
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriodWork::class, inversedBy="goals")
|
||||
*/
|
||||
private $accompanyingPeriodWork;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Goal::class)
|
||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private $goal;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
@@ -36,18 +56,6 @@ class AccompanyingPeriodWorkGoal
|
||||
*/
|
||||
private $note;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriodWork::class, inversedBy="goals")
|
||||
*/
|
||||
private $accompanyingPeriodWork;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Goal::class)
|
||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private $goal;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorkGoals")
|
||||
* @ORM\JoinTable(name="chill_person_accompanying_period_work_goal_result")
|
||||
@@ -61,6 +69,25 @@ class AccompanyingPeriodWorkGoal
|
||||
$this->results = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function addResult(Result $result): self
|
||||
{
|
||||
if (!$this->results->contains($result)) {
|
||||
$this->results[] = $result;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAccompanyingPeriodWork(): ?AccompanyingPeriodWork
|
||||
{
|
||||
return $this->accompanyingPeriodWork;
|
||||
}
|
||||
|
||||
public function getGoal(): ?Goal
|
||||
{
|
||||
return $this->goal;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@@ -71,25 +98,28 @@ class AccompanyingPeriodWorkGoal
|
||||
return $this->note;
|
||||
}
|
||||
|
||||
public function setNote(string $note): self
|
||||
/**
|
||||
* @return Collection|Result[]
|
||||
*/
|
||||
public function getResults(): Collection
|
||||
{
|
||||
$this->note = $note;
|
||||
|
||||
return $this;
|
||||
return $this->results;
|
||||
}
|
||||
|
||||
public function getAccompanyingPeriodWork(): ?AccompanyingPeriodWork
|
||||
public function removeResult(Result $result): self
|
||||
{
|
||||
return $this->accompanyingPeriodWork;
|
||||
$this->results->removeElement($result);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setAccompanyingPeriodWork(?AccompanyingPeriodWork $accompanyingPeriodWork): self
|
||||
{
|
||||
if ($this->accompanyingPeriodWork instanceof AccompanyingPeriodWork
|
||||
&& $accompanyingPeriodWork !== $this->accompanyingPeriodWork
|
||||
&& $accompanyingPeriodWork !== null
|
||||
&& null !== $accompanyingPeriodWork
|
||||
) {
|
||||
throw new \LogicException("Change accompanying period work is not allowed");
|
||||
throw new LogicException('Change accompanying period work is not allowed');
|
||||
}
|
||||
|
||||
$this->accompanyingPeriodWork = $accompanyingPeriodWork;
|
||||
@@ -97,11 +127,6 @@ class AccompanyingPeriodWorkGoal
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getGoal(): ?Goal
|
||||
{
|
||||
return $this->goal;
|
||||
}
|
||||
|
||||
public function setGoal(?Goal $goal): self
|
||||
{
|
||||
$this->goal = $goal;
|
||||
@@ -109,26 +134,9 @@ class AccompanyingPeriodWorkGoal
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Result[]
|
||||
*/
|
||||
public function getResults(): Collection
|
||||
public function setNote(string $note): self
|
||||
{
|
||||
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);
|
||||
$this->note = $note;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@@ -1,33 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS,
|
||||
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* ClosingMotive give an explanation why we closed the Accompanying period
|
||||
* ClosingMotive give an explanation why we closed the Accompanying period.
|
||||
*
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_person_accompanying_period_closingmotive")
|
||||
@@ -35,7 +22,25 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
class ClosingMotive
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
* @var bool
|
||||
*
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private $active = true;
|
||||
|
||||
/**
|
||||
* Child Accompanying periods.
|
||||
*
|
||||
* @var Collection
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive",
|
||||
* mappedBy="parent")
|
||||
*/
|
||||
private $children;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
@@ -49,41 +54,23 @@ class ClosingMotive
|
||||
* @ORM\Column(type="json")
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private $active = true;
|
||||
|
||||
/**
|
||||
* @var self
|
||||
*
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive",
|
||||
* inversedBy="children")
|
||||
*/
|
||||
private $parent = null;
|
||||
|
||||
/**
|
||||
* Child Accompanying periods
|
||||
* @var Collection
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive",
|
||||
* mappedBy="parent")
|
||||
*/
|
||||
private $children;
|
||||
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*
|
||||
* @ORM\Column(type="float")
|
||||
*/
|
||||
private $ordering = 0.0;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @var self
|
||||
*
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive",
|
||||
* inversedBy="children")
|
||||
*/
|
||||
private $parent;
|
||||
|
||||
/**
|
||||
* ClosingMotive constructor.
|
||||
*/
|
||||
@@ -91,11 +78,28 @@ class ClosingMotive
|
||||
{
|
||||
$this->children = new ArrayCollection();
|
||||
}
|
||||
|
||||
|
||||
public function addChildren(ClosingMotive $child): ClosingMotive
|
||||
{
|
||||
if ($this->children->contains($child)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->children->add($child);
|
||||
$child->setParent($this);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChildren(): Collection
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
* Get id.
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
@@ -103,7 +107,87 @@ class ClosingMotive
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name
|
||||
* Get name.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getOrdering(): float
|
||||
{
|
||||
return $this->ordering;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ClosingMotive
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
public function hasParent(): bool
|
||||
{
|
||||
return null !== $this->parent;
|
||||
}
|
||||
|
||||
public function isActive(): bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
public function isChild(): bool
|
||||
{
|
||||
return null !== $this->parent;
|
||||
}
|
||||
|
||||
public function isLeaf(): bool
|
||||
{
|
||||
return $this->children->count() === 0;
|
||||
}
|
||||
|
||||
public function isParent(): bool
|
||||
{
|
||||
return $this->children->count() > 0;
|
||||
}
|
||||
|
||||
public function removeChildren(ClosingMotive $child): ClosingMotive
|
||||
{
|
||||
if ($this->children->removeElement($child)) {
|
||||
$child->setParent(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setActive(bool $active)
|
||||
{
|
||||
$this->active = $active;
|
||||
|
||||
if (false === $this->active) {
|
||||
foreach ($this->getChildren() as $child) {
|
||||
$child->setActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setChildren(Collection $children): ClosingMotive
|
||||
{
|
||||
$this->children = $children;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name.
|
||||
*
|
||||
* @param array $name
|
||||
*
|
||||
@@ -117,161 +201,23 @@ class ClosingMotive
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isActive(): bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $active
|
||||
* @return $this
|
||||
*/
|
||||
public function setActive(bool $active)
|
||||
{
|
||||
$this->active = $active;
|
||||
|
||||
if ($this->active === FALSE) {
|
||||
foreach ($this->getChildren() as $child) {
|
||||
$child->setActive(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ClosingMotive
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getChildren(): Collection
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ClosingMotive|null $parent
|
||||
* @return ClosingMotive
|
||||
*/
|
||||
public function setParent(?ClosingMotive $parent): ClosingMotive
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
if (NULL !== $parent) {
|
||||
//$parent->addChildren($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $children
|
||||
* @return ClosingMotive
|
||||
*/
|
||||
public function setChildren(Collection $children): ClosingMotive
|
||||
{
|
||||
$this->children = $children;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ClosingMotive $child
|
||||
* @return ClosingMotive
|
||||
*/
|
||||
public function addChildren(ClosingMotive $child): ClosingMotive
|
||||
{
|
||||
if ($this->children->contains($child)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->children->add($child);
|
||||
$child->setParent($this);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ClosingMotive $child
|
||||
* @return ClosingMotive
|
||||
*/
|
||||
public function removeChildren(ClosingMotive $child): ClosingMotive
|
||||
{
|
||||
if ($this->children->removeElement($child)) {
|
||||
$child->setParent(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getOrdering(): float
|
||||
{
|
||||
return $this->ordering;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $ordering
|
||||
* @return $this
|
||||
*/
|
||||
public function setOrdering(float $ordering)
|
||||
{
|
||||
$this->ordering = $ordering;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isChild(): bool
|
||||
{
|
||||
return $this->parent !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isParent(): bool
|
||||
{
|
||||
return $this->children->count() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isLeaf(): bool
|
||||
{
|
||||
return $this->children->count() === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasParent(): bool
|
||||
{
|
||||
return $this->parent !== null;
|
||||
}
|
||||
|
||||
public function setParent(?ClosingMotive $parent): ClosingMotive
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
if (null !== $parent) {
|
||||
//$parent->addChildren($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,60 +1,52 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS,
|
||||
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_person_accompanying_period_comment")
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "accompanying_period_comment"=Comment::class
|
||||
* "accompanying_period_comment": Comment::class
|
||||
* })
|
||||
*/
|
||||
class Comment implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod",
|
||||
* inversedBy="comments")
|
||||
* inversedBy="comments")
|
||||
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
|
||||
*/
|
||||
private $accompanyingPeriod;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text")
|
||||
* @Groups({"read", "write"})
|
||||
*/
|
||||
private $content;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime")
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private $createdAt;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
@@ -63,10 +55,12 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface
|
||||
private $creator;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private $createdAt;
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime")
|
||||
@@ -81,20 +75,39 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface
|
||||
*/
|
||||
private $updatedBy;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text")
|
||||
* @Groups({"read", "write"})
|
||||
*/
|
||||
private $content;
|
||||
public function getAccompanyingPeriod(): ?AccompanyingPeriod
|
||||
{
|
||||
return $this->accompanyingPeriod;
|
||||
}
|
||||
|
||||
public function getContent(): ?string
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): ?DateTimeInterface
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function getCreator(): ?User
|
||||
{
|
||||
return $this->creator;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getAccompanyingPeriod(): ?AccompanyingPeriod
|
||||
public function getUpdatedAt(): ?DateTimeInterface
|
||||
{
|
||||
return $this->accompanyingPeriod;
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
public function getUpdatedBy(): ?User
|
||||
{
|
||||
return $this->updatedBy;
|
||||
}
|
||||
|
||||
public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self
|
||||
@@ -104,14 +117,16 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreator(): ?User
|
||||
public function setContent(string $content): self
|
||||
{
|
||||
return $this->creator;
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCreator(?User $creator): self
|
||||
public function setCreatedAt(DateTimeInterface $createdAt): self
|
||||
{
|
||||
$this->creator = $creator;
|
||||
$this->createdAt = $createdAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -121,51 +136,24 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->setCreator($user);
|
||||
}
|
||||
|
||||
public function getCreatedAt(): ?\DateTimeInterface
|
||||
public function setCreator(?User $creator): self
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function setCreatedAt(\DateTimeInterface $createdAt): self
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
$this->creator = $creator;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
|
||||
public function setUpdatedAt(DateTimeInterface $updatedAt): self
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUpdatedBy(): ?User
|
||||
{
|
||||
return $this->updatedBy;
|
||||
}
|
||||
|
||||
public function setUpdatedBy(User $updatedBy): self
|
||||
{
|
||||
$this->updatedBy = $updatedBy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContent(): ?string
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function setContent(string $content): self
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,40 +1,27 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS,
|
||||
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_person_accompanying_period_origin")
|
||||
* @Serializer\DiscriminatorMap(
|
||||
* typeProperty="type",
|
||||
* mapping={
|
||||
* "origin"=Origin::class
|
||||
* })
|
||||
* typeProperty="type",
|
||||
* mapping={
|
||||
* "origin": Origin::class
|
||||
* })
|
||||
*/
|
||||
class Origin
|
||||
{
|
||||
@@ -68,6 +55,11 @@ class Origin
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
public function getNoActiveAfter(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->noActiveAfter;
|
||||
}
|
||||
|
||||
public function setLabel(string $label): self
|
||||
{
|
||||
$this->label = $label;
|
||||
@@ -75,12 +67,7 @@ class Origin
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getNoActiveAfter(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->noActiveAfter;
|
||||
}
|
||||
|
||||
public function setNoActiveAfter(?\DateTimeImmutable $noActiveAfter): self
|
||||
public function setNoActiveAfter(?DateTimeImmutable $noActiveAfter): self
|
||||
{
|
||||
$this->noActiveAfter = $noActiveAfter;
|
||||
|
||||
|
@@ -1,59 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS,
|
||||
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\ResourceRepository;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(
|
||||
* name="chill_person_accompanying_period_resource",
|
||||
* uniqueConstraints={
|
||||
* @ORM\UniqueConstraint(name="person_unique", columns={"person_id", "accompanyingperiod_id"}),
|
||||
* @ORM\UniqueConstraint(name="thirdparty_unique", columns={"thirdparty_id", "accompanyingperiod_id"})
|
||||
* }
|
||||
* name="chill_person_accompanying_period_resource",
|
||||
* uniqueConstraints={
|
||||
* @ORM\UniqueConstraint(name="person_unique", columns={"person_id", "accompanyingperiod_id"}),
|
||||
* @ORM\UniqueConstraint(name="thirdparty_unique", columns={"thirdparty_id", "accompanyingperiod_id"})
|
||||
* }
|
||||
* )
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "accompanying_period_resource"=Resource::class
|
||||
* })
|
||||
* "accompanying_period_resource": Resource::class
|
||||
* })
|
||||
*/
|
||||
class Resource
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod",
|
||||
@@ -64,10 +42,18 @@ class Resource
|
||||
private $accompanyingPeriod;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
|
||||
* @ORM\ManyToOne(targetEntity=Comment::class)
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
private $thirdParty;
|
||||
private $comment;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
@@ -76,38 +62,24 @@ class Resource
|
||||
private $person;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Comment::class)
|
||||
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
private $comment;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
private $thirdParty;
|
||||
|
||||
public function getAccompanyingPeriod(): ?AccompanyingPeriod
|
||||
{
|
||||
return $this->accompanyingPeriod;
|
||||
}
|
||||
|
||||
public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self
|
||||
public function getComment(): ?Comment
|
||||
{
|
||||
$this->accompanyingPeriod = $accompanyingPeriod;
|
||||
|
||||
return $this;
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
public function getThirdParty(): ?ThirdParty
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->thirdParty;
|
||||
}
|
||||
|
||||
private function setThirdParty(?ThirdParty $thirdParty): self
|
||||
{
|
||||
$this->thirdParty = $thirdParty;
|
||||
|
||||
return $this;
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getPerson(): ?Person
|
||||
@@ -115,16 +87,25 @@ class Resource
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
private function setPerson(?Person $person): self
|
||||
/**
|
||||
* @return Person|ThirdParty
|
||||
* @Groups({"read", "write"})
|
||||
*/
|
||||
public function getResource()
|
||||
{
|
||||
$this->person = $person;
|
||||
|
||||
return $this;
|
||||
return $this->person ?? $this->thirdParty;
|
||||
}
|
||||
|
||||
public function getComment(): ?Comment
|
||||
public function getThirdParty(): ?ThirdParty
|
||||
{
|
||||
return $this->comment;
|
||||
return $this->thirdParty;
|
||||
}
|
||||
|
||||
public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self
|
||||
{
|
||||
$this->accompanyingPeriod = $accompanyingPeriod;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setComment(?Comment $comment): self
|
||||
@@ -135,36 +116,42 @@ class Resource
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $resource Person|ThirdParty
|
||||
*/
|
||||
public function setResource($resource): self
|
||||
{
|
||||
if ($resource instanceof ThirdParty) {
|
||||
$this->setThirdParty($resource);
|
||||
$this->setPerson(NULL);
|
||||
$this->setPerson(null);
|
||||
} elseif ($resource instanceof Person) {
|
||||
$this->setPerson($resource);
|
||||
$this->setThirdParty(NULL);
|
||||
} elseif (NULL === $resource) {
|
||||
$this->setPerson(NULL);
|
||||
$this->setThirdParty(NULL);
|
||||
$this->setThirdParty(null);
|
||||
} elseif (null === $resource) {
|
||||
$this->setPerson(null);
|
||||
$this->setThirdParty(null);
|
||||
} else {
|
||||
throw new \UnexpectedValueException(sprintf("the resource ".
|
||||
"should be an instance of %s or %s", Person::class,
|
||||
ThirdParty::class));
|
||||
throw new UnexpectedValueException(sprintf(
|
||||
'the resource ' .
|
||||
'should be an instance of %s or %s',
|
||||
Person::class,
|
||||
ThirdParty::class
|
||||
));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return ThirdParty|Person
|
||||
* @Groups({"read", "write"})
|
||||
*/
|
||||
public function getResource()
|
||||
|
||||
private function setPerson(?Person $person): self
|
||||
{
|
||||
return $this->person ?? $this->thirdParty;
|
||||
$this->person = $person;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function setThirdParty(?ThirdParty $thirdParty): self
|
||||
{
|
||||
$this->thirdParty = $thirdParty;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,45 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS,
|
||||
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
/**
|
||||
* AccompanyingPeriodParticipation Class
|
||||
* AccompanyingPeriodParticipation Class.
|
||||
*
|
||||
* @package Chill\PersonBundle\Entity
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_person_accompanying_period_participation")
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "accompanying_period_participation"=AccompanyingPeriodParticipation::class
|
||||
* })
|
||||
* "accompanying_period_participation": AccompanyingPeriodParticipation::class
|
||||
* })
|
||||
*/
|
||||
class AccompanyingPeriodParticipation
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="participations", cascade={"persist"})
|
||||
* @ORM\JoinColumn(name="accompanyingperiod_id", referencedColumnName="id", nullable=false)
|
||||
*/
|
||||
private $accompanyingPeriod;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date", nullable=true)
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private $endDate;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
@@ -55,31 +53,33 @@ class AccompanyingPeriodParticipation
|
||||
*/
|
||||
private $person;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="participations", cascade={"persist"})
|
||||
* @ORM\JoinColumn(name="accompanyingperiod_id", referencedColumnName="id", nullable=false)
|
||||
*/
|
||||
private $accompanyingPeriod;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date", nullable=false)
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private $startDate;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date", nullable=true)
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private $endDate = null;
|
||||
|
||||
public function __construct(AccompanyingPeriod $accompanyingPeriod, Person $person)
|
||||
{
|
||||
$this->startDate = new \DateTimeImmutable('now');
|
||||
$this->startDate = new DateTimeImmutable('now');
|
||||
$this->accompanyingPeriod = $accompanyingPeriod;
|
||||
$this->person = $person;
|
||||
}
|
||||
|
||||
public function getAccompanyingPeriod(): ?AccompanyingPeriod
|
||||
{
|
||||
return $this->accompanyingPeriod;
|
||||
}
|
||||
|
||||
/*
|
||||
* public function setStartDate(\DateTimeInterface $startDate): self { $this->startDate = $startDate; return $this; }
|
||||
*/
|
||||
|
||||
public function getEndDate(): ?DateTimeInterface
|
||||
{
|
||||
return $this->endDate;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@@ -90,16 +90,14 @@ class AccompanyingPeriodParticipation
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
public function setPerson(?Person $person): self
|
||||
public function getStartDate(): ?DateTimeInterface
|
||||
{
|
||||
$this->person = $person;
|
||||
|
||||
return $this;
|
||||
return $this->startDate;
|
||||
}
|
||||
|
||||
public function getAccompanyingPeriod(): ?AccompanyingPeriod
|
||||
public function isOpen(): bool
|
||||
{
|
||||
return $this->accompanyingPeriod;
|
||||
return null === $this->endDate;
|
||||
}
|
||||
|
||||
public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self
|
||||
@@ -109,35 +107,23 @@ class AccompanyingPeriodParticipation
|
||||
return $this;
|
||||
}
|
||||
|
||||
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): self
|
||||
public function setEndDate(?DateTimeInterface $endDate): self
|
||||
{
|
||||
$this->endDate = $endDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isOpen(): bool
|
||||
public function setPerson(?Person $person): self
|
||||
{
|
||||
return $this->endDate === null;
|
||||
$this->person = $person;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function checkSameStartEnd()
|
||||
private function checkSameStartEnd()
|
||||
{
|
||||
if($this->endDate == $this->startDate) {
|
||||
if ($this->endDate == $this->startDate) {
|
||||
$this->accompanyingPeriod->removeParticipation($this);
|
||||
}
|
||||
}
|
||||
|
@@ -1,34 +1,20 @@
|
||||
<?php
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014-2019, Champs Libres Cooperative SCRLFS,
|
||||
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
namespace Chill\PersonBundle\Entity;
|
||||
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
|
||||
/**
|
||||
* Interface which applies to entities which are associated to a single person
|
||||
*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity;
|
||||
|
||||
/**
|
||||
* Interface which applies to entities which are associated to a single person.
|
||||
*/
|
||||
interface HasPerson
|
||||
{
|
||||
public function setPerson(Person $person = null): HasPerson;
|
||||
|
||||
public function getPerson(): ?Person;
|
||||
|
||||
public function setPerson(?Person $person = null): HasPerson;
|
||||
}
|
||||
|
@@ -1,31 +1,57 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity\Household;
|
||||
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||
use Chill\PersonBundle\Validator\Constraints\Household\MaxHolder;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||
use Chill\PersonBundle\Validator\Constraints\Household\MaxHolder;
|
||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(
|
||||
* name="chill_person_household"
|
||||
* )
|
||||
* name="chill_person_household"
|
||||
* )
|
||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "household"=Household::class
|
||||
* "household": Household::class
|
||||
* })
|
||||
* @MaxHolder(groups={"household_memberships"})
|
||||
*/
|
||||
class Household
|
||||
{
|
||||
/**
|
||||
* Addresses.
|
||||
*
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\MainBundle\Entity\Address",
|
||||
* cascade={"persist", "remove", "merge", "detach"})
|
||||
* @ORM\JoinTable(name="chill_person_household_to_addresses")
|
||||
* @ORM\OrderBy({"validFrom": "DESC", "id": "DESC"})
|
||||
* @Serializer\Groups({"write"})
|
||||
*/
|
||||
private Collection $addresses;
|
||||
|
||||
/**
|
||||
* @ORM\Embedded(class=CommentEmbeddable::class, columnPrefix="comment_members_")
|
||||
*/
|
||||
private CommentEmbeddable $commentMembers;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
@@ -34,32 +60,15 @@ class Household
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* Addresses
|
||||
*
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\MainBundle\Entity\Address",
|
||||
* cascade={"persist", "remove", "merge", "detach"})
|
||||
* @ORM\JoinTable(name="chill_person_household_to_addresses")
|
||||
* @ORM\OrderBy({"validFrom" = "DESC", "id" = "DESC"})
|
||||
* @Serializer\Groups({"write"})
|
||||
*/
|
||||
private Collection $addresses;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=HouseholdMember::class,
|
||||
* mappedBy="household"
|
||||
* )
|
||||
* targetEntity=HouseholdMember::class,
|
||||
* mappedBy="household"
|
||||
* )
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private Collection $members;
|
||||
|
||||
/**
|
||||
* @ORM\Embedded(class=CommentEmbeddable::class, columnPrefix="comment_members_")
|
||||
*/
|
||||
private CommentEmbeddable $commentMembers;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", name="waiting_for_birth", options={"default": false})
|
||||
*/
|
||||
@@ -68,7 +77,7 @@ class Household
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", name="waiting_for_birth_date", nullable=true, options={"default": null})
|
||||
*/
|
||||
private ?\DateTimeImmutable $waitingForBirthDate = null;
|
||||
private ?DateTimeImmutable $waitingForBirthDate = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -77,19 +86,13 @@ class Household
|
||||
$this->commentMembers = new CommentEmbeddable();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Address $address
|
||||
* @return $this
|
||||
*/
|
||||
public function addAddress(Address $address)
|
||||
{
|
||||
foreach ($this->getAddresses() as $a) {
|
||||
if ($a->getValidFrom() < $address->getValidFrom() && $a->getValidTo() === NULL) {
|
||||
if ($a->getValidFrom() < $address->getValidFrom() && $a->getValidTo() === null) {
|
||||
$a->setValidTo($address->getValidFrom());
|
||||
}
|
||||
}
|
||||
@@ -99,35 +102,22 @@ class Household
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force an address starting at the current day
|
||||
* on the Household.
|
||||
*
|
||||
* This will force the startDate's address on today.
|
||||
*
|
||||
* Used on household creation.
|
||||
*
|
||||
* @Serializer\Groups({"create"})
|
||||
*/
|
||||
public function setForceAddress(Address $address)
|
||||
public function addMember(HouseholdMember $member): self
|
||||
{
|
||||
$address->setValidFrom(new \DateTime('today'));
|
||||
$this->addAddress($address);
|
||||
}
|
||||
if (!$this->members->contains($member)) {
|
||||
$this->members[] = $member;
|
||||
$member->setHousehold($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Address $address
|
||||
*/
|
||||
public function removeAddress(Address $address)
|
||||
{
|
||||
$this->addresses->removeElement($address);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, the addresses are ordered by date, descending (the most
|
||||
* recent first)
|
||||
* recent first).
|
||||
*
|
||||
* @Assert\Callback(methods={"validate"})
|
||||
*
|
||||
* @return \Chill\MainBundle\Entity\Address[]
|
||||
*/
|
||||
public function getAddresses()
|
||||
@@ -135,25 +125,131 @@ class Household
|
||||
return $this->addresses;
|
||||
}
|
||||
|
||||
public function getCommentMembers(): CommentEmbeddable
|
||||
{
|
||||
return $this->commentMembers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Serializer\Groups({ "read" })
|
||||
* @Serializer\SerializedName("current_address")
|
||||
*/
|
||||
public function getCurrentAddress(\DateTime $at = null): ?Address
|
||||
public function getCurrentAddress(?DateTime $at = null): ?Address
|
||||
{
|
||||
$at = $at === null ? new \DateTime('today') : $at;
|
||||
$at = null === $at ? new DateTime('today') : $at;
|
||||
|
||||
$addrs = $this->getAddresses()->filter(function (Address $a) use ($at) {
|
||||
return $a->getValidFrom() <= $at && (
|
||||
NULL === $a->getValidTo() || $at < $a->getValidTo()
|
||||
null === $a->getValidTo() || $a->getValidTo() > $at
|
||||
);
|
||||
});
|
||||
|
||||
if ($addrs->count() > 0) {
|
||||
return $addrs->first();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getCurrentMembers(?DateTimeImmutable $now = null): Collection
|
||||
{
|
||||
return $this->getMembers()->matching($this->buildCriteriaCurrentMembers($now));
|
||||
}
|
||||
|
||||
public function getCurrentMembersByPosition(Position $position, ?DateTimeInterface $now = null)
|
||||
{
|
||||
$criteria = new Criteria();
|
||||
$expr = Criteria::expr();
|
||||
|
||||
$criteria->where($expr->eq('position', $position));
|
||||
|
||||
return $this->getCurrentMembers($now)->matching($criteria);
|
||||
}
|
||||
|
||||
/**
|
||||
* get current members ids.
|
||||
*
|
||||
* Used in serialization
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\SerializedName("current_members_id")
|
||||
*/
|
||||
public function getCurrentMembersIds(?DateTimeImmutable $now = null): Collection
|
||||
{
|
||||
return $this->getCurrentMembers($now)->map(
|
||||
fn (HouseholdMember $m) => $m->getId()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HouseholdMember[]
|
||||
*/
|
||||
public function getCurrentMembersOrdered(?DateTimeImmutable $now = null): Collection
|
||||
{
|
||||
$members = $this->getCurrentMembers($now);
|
||||
|
||||
$members->getIterator()
|
||||
->uasort(
|
||||
function (HouseholdMember $a, HouseholdMember $b) {
|
||||
if ($a->getPosition() === null) {
|
||||
if ($b->getPosition() === null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
} elseif ($b->getPosition() === null) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ($a->getPosition()->getOrdering() < $b->getPosition()->getOrdering()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ($a->getPosition()->getOrdering() > $b->getPosition()->getOrdering()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ($a->isHolder() && !$b->isHolder()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!$a->isHolder() && $b->isHolder()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
);
|
||||
|
||||
return $members;
|
||||
}
|
||||
|
||||
public function getCurrentMembersWithoutPosition(?DateTimeInterface $now = null)
|
||||
{
|
||||
$criteria = new Criteria();
|
||||
$expr = Criteria::expr();
|
||||
|
||||
$criteria->where($expr->isNull('position'));
|
||||
|
||||
return $this->getCurrentMembers($now)->matching($criteria);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the persons currently associated to the household.
|
||||
*
|
||||
* Return a list of Person, instead of a list of HouseholdMembers
|
||||
*
|
||||
* @return Person[]
|
||||
*/
|
||||
public function getCurrentPersons(?DateTimeImmutable $now = null): Collection
|
||||
{
|
||||
return $this->getCurrentMembers($now)
|
||||
->map(function (HouseholdMember $m) { return $m->getPerson(); });
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,36 +260,13 @@ class Household
|
||||
return $this->members;
|
||||
}
|
||||
|
||||
public function getMembersOnRange(\DateTimeImmutable $from, ?\DateTimeImmutable $to): Collection
|
||||
{
|
||||
$criteria = new Criteria();
|
||||
$expr = Criteria::expr();
|
||||
|
||||
$criteria->where(
|
||||
$expr->gte('startDate', $from)
|
||||
);
|
||||
|
||||
if (NULL !== $to) {
|
||||
$criteria->andWhere(
|
||||
$expr->orX(
|
||||
$expr->lte('endDate', $to),
|
||||
$expr->eq('endDate', NULL)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return $this->getMembers()
|
||||
->matching($criteria)
|
||||
;
|
||||
}
|
||||
|
||||
public function getMembersDuringMembership(HouseholdMember $membership)
|
||||
{
|
||||
return $this->getMembersOnRange(
|
||||
$membership->getStartDate(),
|
||||
$membership->getEndDate()
|
||||
)->filter(
|
||||
function(HouseholdMember $m) use ($membership) {
|
||||
function (HouseholdMember $m) use ($membership) {
|
||||
return $m !== $membership;
|
||||
}
|
||||
);
|
||||
@@ -211,104 +284,33 @@ class Household
|
||||
return $this->getMembers()->matching($criteria);
|
||||
}
|
||||
|
||||
public function getCurrentMembers(?\DateTimeImmutable $now = null): Collection
|
||||
{
|
||||
return $this->getMembers()->matching($this->buildCriteriaCurrentMembers($now));
|
||||
}
|
||||
|
||||
private function buildCriteriaCurrentMembers(?\DateTimeImmutable $now = null): Criteria
|
||||
public function getMembersOnRange(DateTimeImmutable $from, ?DateTimeImmutable $to): Collection
|
||||
{
|
||||
$criteria = new Criteria();
|
||||
$expr = Criteria::expr();
|
||||
$date = $now === null ? (new \DateTimeImmutable('today')) : $now;
|
||||
|
||||
$criteria
|
||||
->where($expr->orX(
|
||||
$expr->isNull('startDate'),
|
||||
$expr->lte('startDate', $date)
|
||||
))
|
||||
->andWhere($expr->orX(
|
||||
$expr->isNull('endDate'),
|
||||
$expr->gt('endDate', $date)
|
||||
));
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HouseholdMember[]
|
||||
*/
|
||||
public function getCurrentMembersOrdered(?\DateTimeImmutable $now = null): Collection
|
||||
{
|
||||
$members = $this->getCurrentMembers($now);
|
||||
|
||||
$members->getIterator()
|
||||
->uasort(
|
||||
function (HouseholdMember $a, HouseholdMember $b) {
|
||||
if ($a->getPosition() === NULL) {
|
||||
if ($b->getPosition() === NULL) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} elseif ($b->getPosition() === NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ($a->getPosition()->getOrdering() < $b->getPosition()->getOrdering()) {
|
||||
return -1;
|
||||
}
|
||||
if ($a->getPosition()->getOrdering() > $b->getPosition()->getOrdering()) {
|
||||
return 1;
|
||||
}
|
||||
if ($a->isHolder() && !$b->isHolder()) {
|
||||
return 1;
|
||||
}
|
||||
if (!$a->isHolder() && $b->isHolder()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
$criteria->where(
|
||||
$expr->gte('startDate', $from)
|
||||
);
|
||||
|
||||
return $members;
|
||||
if (null !== $to) {
|
||||
$criteria->andWhere(
|
||||
$expr->orX(
|
||||
$expr->lte('endDate', $to),
|
||||
$expr->eq('endDate', null)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return $this->getMembers()
|
||||
->matching($criteria);
|
||||
}
|
||||
|
||||
/**
|
||||
* get current members ids
|
||||
*
|
||||
* Used in serialization
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\SerializedName("current_members_id")
|
||||
*
|
||||
*/
|
||||
public function getCurrentMembersIds(?\DateTimeImmutable $now = null): Collection
|
||||
{
|
||||
return $this->getCurrentMembers($now)->map(
|
||||
fn (HouseholdMember $m) => $m->getId()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the persons currently associated to the household.
|
||||
*
|
||||
* Return a list of Person, instead of a list of HouseholdMembers
|
||||
*
|
||||
* @return Person[]
|
||||
*/
|
||||
public function getCurrentPersons(?\DateTimeImmutable $now = null): Collection
|
||||
{
|
||||
return $this->getCurrentMembers($now)
|
||||
->map(function(HouseholdMember $m) { return $m->getPerson(); });
|
||||
}
|
||||
|
||||
public function getNonCurrentMembers(\DateTimeImmutable $now = null): Collection
|
||||
public function getNonCurrentMembers(?DateTimeImmutable $now = null): Collection
|
||||
{
|
||||
$criteria = new Criteria();
|
||||
$expr = Criteria::expr();
|
||||
$date = $now === null ? (new \DateTimeImmutable('today')) : $now;
|
||||
$date = null === $now ? (new DateTimeImmutable('today')) : $now;
|
||||
|
||||
$criteria
|
||||
->where(
|
||||
@@ -324,17 +326,7 @@ class Household
|
||||
return $this->getMembers()->matching($criteria);
|
||||
}
|
||||
|
||||
public function getCurrentMembersByPosition(Position $position, \DateTimeInterface $now = null)
|
||||
{
|
||||
$criteria = new Criteria();
|
||||
$expr = Criteria::expr();
|
||||
|
||||
$criteria->where($expr->eq('position', $position));
|
||||
|
||||
return $this->getCurrentMembers($now)->matching($criteria);
|
||||
}
|
||||
|
||||
public function getNonCurrentMembersByPosition(Position $position, \DateTimeInterface $now = null)
|
||||
public function getNonCurrentMembersByPosition(Position $position, ?DateTimeInterface $now = null)
|
||||
{
|
||||
$criteria = new Criteria();
|
||||
$expr = Criteria::expr();
|
||||
@@ -344,17 +336,7 @@ class Household
|
||||
return $this->getNonCurrentMembers($now)->matching($criteria);
|
||||
}
|
||||
|
||||
public function getCurrentMembersWithoutPosition(\DateTimeInterface $now = null)
|
||||
{
|
||||
$criteria = new Criteria();
|
||||
$expr = Criteria::expr();
|
||||
|
||||
$criteria->where($expr->isNull('position'));
|
||||
|
||||
return $this->getCurrentMembers($now)->matching($criteria);
|
||||
}
|
||||
|
||||
public function getNonCurrentMembersWithoutPosition(\DateTimeInterface $now = null)
|
||||
public function getNonCurrentMembersWithoutPosition(?DateTimeInterface $now = null)
|
||||
{
|
||||
$criteria = new Criteria();
|
||||
$expr = Criteria::expr();
|
||||
@@ -364,14 +346,19 @@ class Household
|
||||
return $this->getNonCurrentMembers($now)->matching($criteria);
|
||||
}
|
||||
|
||||
public function addMember(HouseholdMember $member): self
|
||||
public function getWaitingForBirth(): bool
|
||||
{
|
||||
if (!$this->members->contains($member)) {
|
||||
$this->members[] = $member;
|
||||
$member->setHousehold($this);
|
||||
}
|
||||
return $this->waitingForBirth;
|
||||
}
|
||||
|
||||
return $this;
|
||||
public function getWaitingForBirthDate(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->waitingForBirthDate;
|
||||
}
|
||||
|
||||
public function removeAddress(Address $address)
|
||||
{
|
||||
$this->addresses->removeElement($address);
|
||||
}
|
||||
|
||||
public function removeMember(HouseholdMember $member): self
|
||||
@@ -386,11 +373,6 @@ class Household
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCommentMembers(): CommentEmbeddable
|
||||
{
|
||||
return $this->commentMembers;
|
||||
}
|
||||
|
||||
public function setCommentMembers(CommentEmbeddable $commentMembers): self
|
||||
{
|
||||
$this->commentMembers = $commentMembers;
|
||||
@@ -398,9 +380,20 @@ class Household
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getWaitingForBirth(): bool
|
||||
/**
|
||||
* Force an address starting at the current day
|
||||
* on the Household.
|
||||
*
|
||||
* This will force the startDate's address on today.
|
||||
*
|
||||
* Used on household creation.
|
||||
*
|
||||
* @Serializer\Groups({"create"})
|
||||
*/
|
||||
public function setForceAddress(Address $address)
|
||||
{
|
||||
return $this->waitingForBirth;
|
||||
$address->setValidFrom(new DateTime('today'));
|
||||
$this->addAddress($address);
|
||||
}
|
||||
|
||||
public function setWaitingForBirth(bool $waitingForBirth): self
|
||||
@@ -410,12 +403,7 @@ class Household
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getWaitingForBirthDate(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->waitingForBirthDate;
|
||||
}
|
||||
|
||||
public function setWaitingForBirthDate(?\DateTimeImmutable $waitingForBirthDate): self
|
||||
public function setWaitingForBirthDate(?DateTimeImmutable $waitingForBirthDate): self
|
||||
{
|
||||
$this->waitingForBirthDate = $waitingForBirthDate;
|
||||
|
||||
@@ -425,14 +413,34 @@ class Household
|
||||
public function validate(ExecutionContextInterface $context, $payload)
|
||||
{
|
||||
$addresses = $this->getAddresses();
|
||||
$cond = True;
|
||||
for ($i=0; $i < count($addresses) - 1; $i++) {
|
||||
$cond = true;
|
||||
|
||||
for ($i = 0; count($addresses) - 1 > $i; ++$i) {
|
||||
if ($addresses[$i]->getValidFrom() != $addresses[$i + 1]->getValidTo()) {
|
||||
$cond = False;
|
||||
$cond = false;
|
||||
$context->buildViolation('The address are not sequentials. The validFrom date of one address should be equal to the validTo date of the previous address.')
|
||||
->atPath('addresses')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function buildCriteriaCurrentMembers(?DateTimeImmutable $now = null): Criteria
|
||||
{
|
||||
$criteria = new Criteria();
|
||||
$expr = Criteria::expr();
|
||||
$date = null === $now ? (new DateTimeImmutable('today')) : $now;
|
||||
|
||||
$criteria
|
||||
->where($expr->orX(
|
||||
$expr->isNull('startDate'),
|
||||
$expr->lte('startDate', $date)
|
||||
))
|
||||
->andWhere($expr->orX(
|
||||
$expr->isNull('endDate'),
|
||||
$expr->gt('endDate', $date)
|
||||
));
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
}
|
||||
|
@@ -1,23 +1,62 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity\Household;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Household\Position;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use LogicException;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(
|
||||
* name="chill_person_household_members"
|
||||
* )
|
||||
* name="chill_person_household_members"
|
||||
* )
|
||||
*/
|
||||
class HouseholdMember
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?string $comment = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Assert\GreaterThan(
|
||||
* propertyPath="startDate",
|
||||
* message="household_membership.The end date must be after start date",
|
||||
* groups={"household_memberships"}
|
||||
* )
|
||||
*/
|
||||
private ?DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", options={"default": false})
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private bool $holder = false;
|
||||
|
||||
/**
|
||||
* @var Household
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="\Chill\PersonBundle\Entity\Household\Household"
|
||||
* )
|
||||
* @Assert\Valid(groups={"household_memberships"})
|
||||
* @Assert\NotNull(groups={"household_memberships"})
|
||||
*/
|
||||
private ?Household $household = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
@@ -27,52 +66,9 @@ class HouseholdMember
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Position::class)
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Assert\NotNull(groups={"household_memberships_created"})
|
||||
*/
|
||||
private ?Position $position = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Assert\NotNull(groups={"household_memberships"})
|
||||
*/
|
||||
private ?\DateTimeImmutable $startDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable= true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Assert\GreaterThan(
|
||||
* propertyPath="startDate",
|
||||
* message="household_membership.The end date must be after start date",
|
||||
* groups={"household_memberships"}
|
||||
* )
|
||||
*/
|
||||
private ?\DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?string $comment = NULL;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", name="sharedhousehold")
|
||||
*/
|
||||
private bool $shareHousehold = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", options={"default": false})
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private bool $holder = false;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Person
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="\Chill\PersonBundle\Entity\Person"
|
||||
* targetEntity="\Chill\PersonBundle\Entity\Person"
|
||||
* )
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Assert\Valid(groups={"household_memberships"})
|
||||
@@ -81,74 +77,52 @@ class HouseholdMember
|
||||
private ?Person $person = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Household
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="\Chill\PersonBundle\Entity\Household\Household"
|
||||
* )
|
||||
* @Assert\Valid(groups={"household_memberships"})
|
||||
* @ORM\ManyToOne(targetEntity=Position::class)
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Assert\NotNull(groups={"household_memberships_created"})
|
||||
*/
|
||||
private ?Position $position = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", name="sharedhousehold")
|
||||
*/
|
||||
private bool $shareHousehold = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Assert\NotNull(groups={"household_memberships"})
|
||||
*/
|
||||
private ?Household $household = null;
|
||||
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getPosition(): ?Position
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
public function setPosition(Position $position): self
|
||||
{
|
||||
if ($this->position instanceof Position) {
|
||||
throw new \LogicException("The position is already set. You cannot change ".
|
||||
"a position of a membership");
|
||||
}
|
||||
|
||||
$this->position = $position;
|
||||
$this->shareHousehold = $position->getShareHousehold();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStartDate(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->startDate;
|
||||
}
|
||||
|
||||
public function setStartDate(\DateTimeImmutable $startDate): self
|
||||
{
|
||||
$this->startDate = $startDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEndDate(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->endDate;
|
||||
}
|
||||
|
||||
public function setEndDate(?\DateTimeImmutable $endDate = null): self
|
||||
{
|
||||
$this->endDate = $endDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
private ?DateTimeImmutable $startDate = null;
|
||||
|
||||
public function getComment(): ?string
|
||||
{
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
public function setComment(?string $comment): self
|
||||
public function getEndDate(): ?DateTimeImmutable
|
||||
{
|
||||
$this->comment = $comment;
|
||||
return $this->endDate;
|
||||
}
|
||||
|
||||
return $this;
|
||||
public function getHousehold(): ?Household
|
||||
{
|
||||
return $this->household;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getPerson(): ?Person
|
||||
{
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
public function getPosition(): ?Position
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,44 +133,35 @@ class HouseholdMember
|
||||
return $this->shareHousehold;
|
||||
}
|
||||
|
||||
public function setShareHousehold(bool $shareHousehold): self
|
||||
public function getStartDate(): ?DateTimeImmutable
|
||||
{
|
||||
$this->shareHousehold = $shareHousehold;
|
||||
return $this->startDate;
|
||||
}
|
||||
|
||||
public function isCurrent(?DateTimeImmutable $at = null): bool
|
||||
{
|
||||
$at = null === $at ? new DateTimeImmutable('now') : $at;
|
||||
|
||||
return $this->getStartDate() < $at && (
|
||||
null === $this->getEndDate() || $this->getEndDate() > $at
|
||||
);
|
||||
}
|
||||
|
||||
public function isHolder(): bool
|
||||
{
|
||||
return $this->holder;
|
||||
}
|
||||
|
||||
public function setComment(?string $comment): self
|
||||
{
|
||||
$this->comment = $comment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPerson(): ?Person
|
||||
public function setEndDate(?DateTimeImmutable $endDate = null): self
|
||||
{
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
public function setPerson(?Person $person): self
|
||||
{
|
||||
if ($this->person instanceof Person) {
|
||||
throw new \LogicException("You cannot change person ".
|
||||
"on a membership");
|
||||
}
|
||||
|
||||
$this->person = $person;
|
||||
$this->person->addHouseholdParticipation($this);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHousehold(): ?Household
|
||||
{
|
||||
return $this->household;
|
||||
}
|
||||
|
||||
public function setHousehold(?Household $household): self
|
||||
{
|
||||
if ($this->household instanceof Household) {
|
||||
throw new \LogicException("You cannot change household ".
|
||||
"on a membership");
|
||||
}
|
||||
|
||||
$this->household = $household;
|
||||
$this->endDate = $endDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -208,17 +173,55 @@ class HouseholdMember
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isHolder(): bool
|
||||
public function setHousehold(?Household $household): self
|
||||
{
|
||||
return $this->holder;
|
||||
if ($this->household instanceof Household) {
|
||||
throw new LogicException('You cannot change household ' .
|
||||
'on a membership');
|
||||
}
|
||||
|
||||
$this->household = $household;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isCurrent(\DateTimeImmutable $at = null): bool
|
||||
public function setPerson(?Person $person): self
|
||||
{
|
||||
$at = NULL === $at ? new \DateTimeImmutable('now'): $at;
|
||||
if ($this->person instanceof Person) {
|
||||
throw new LogicException('You cannot change person ' .
|
||||
'on a membership');
|
||||
}
|
||||
|
||||
return $this->getStartDate() < $at && (
|
||||
NULL === $this->getEndDate() || $at < $this->getEndDate()
|
||||
);
|
||||
$this->person = $person;
|
||||
$this->person->addHouseholdParticipation($this);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPosition(Position $position): self
|
||||
{
|
||||
if ($this->position instanceof Position) {
|
||||
throw new LogicException('The position is already set. You cannot change ' .
|
||||
'a position of a membership');
|
||||
}
|
||||
|
||||
$this->position = $position;
|
||||
$this->shareHousehold = $position->getShareHousehold();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setShareHousehold(bool $shareHousehold): self
|
||||
{
|
||||
$this->shareHousehold = $shareHousehold;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setStartDate(DateTimeImmutable $startDate): self
|
||||
{
|
||||
$this->startDate = $startDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity\Household;
|
||||
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
@@ -36,6 +44,26 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
*/
|
||||
class PersonHouseholdAddress
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\ManyToOne(targetEntity=Address::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private $address;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\ManyToOne(targetEntity=Household::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private $household;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private $person;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable")
|
||||
@@ -47,52 +75,9 @@ class PersonHouseholdAddress
|
||||
*/
|
||||
private $validTo;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private $person;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\ManyToOne(targetEntity=Household::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private $household;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\ManyToOne(targetEntity=Address::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private $address;
|
||||
|
||||
/**
|
||||
* The start date of the intersection address/household
|
||||
*
|
||||
* (this is not the startdate of the household, not
|
||||
* the startdate of the address)
|
||||
*/
|
||||
public function getValidFrom(): ?\DateTimeInterface
|
||||
public function getAddress(): ?Address
|
||||
{
|
||||
return $this->validFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* The end date of the intersection address/household
|
||||
*
|
||||
* (this is not the enddate of the household, not
|
||||
* the enddate of the address)
|
||||
*/
|
||||
public function getValidTo(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->validTo;
|
||||
}
|
||||
|
||||
public function getPerson(): ?Person
|
||||
{
|
||||
return $this->person;
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
public function getHousehold(): ?Household
|
||||
@@ -100,8 +85,30 @@ class PersonHouseholdAddress
|
||||
return $this->relation;
|
||||
}
|
||||
|
||||
public function getAddress(): ?Address
|
||||
public function getPerson(): ?Person
|
||||
{
|
||||
return $this->address;
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
/**
|
||||
* The start date of the intersection address/household.
|
||||
*
|
||||
* (this is not the startdate of the household, not
|
||||
* the startdate of the address)
|
||||
*/
|
||||
public function getValidFrom(): ?DateTimeInterface
|
||||
{
|
||||
return $this->validFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* The end date of the intersection address/household.
|
||||
*
|
||||
* (this is not the enddate of the household, not
|
||||
* the enddate of the address)
|
||||
*/
|
||||
public function getValidTo(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->validTo;
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity\Household;
|
||||
|
||||
use Chill\PersonBundle\Repository\Household\PositionRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
@@ -10,11 +16,17 @@ use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_person_household_position")
|
||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "household_position"=Position::class
|
||||
* })
|
||||
* "household_position": Position::class
|
||||
* })
|
||||
*/
|
||||
class Position
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
* @Serializer\Groups({ "read" })
|
||||
*/
|
||||
private bool $allowHolder = false;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
@@ -29,23 +41,22 @@ class Position
|
||||
*/
|
||||
private array $label = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="float")
|
||||
* @Serializer\Groups({ "read" })
|
||||
*/
|
||||
private float $ordering = 0.00;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
* @Serializer\Groups({ "read" })
|
||||
*/
|
||||
private bool $shareHouseHold = true;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
* @Serializer\Groups({ "read" })
|
||||
*/
|
||||
private bool $allowHolder = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="float")
|
||||
* @Serializer\Groups({ "read" })
|
||||
*/
|
||||
private float $ordering = 0.00;
|
||||
public function getAllowHolder(): bool
|
||||
{
|
||||
return $this->allowHolder;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
@@ -57,11 +68,9 @@ class Position
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
public function setLabel(array $label): self
|
||||
public function getOrdering(): float
|
||||
{
|
||||
$this->label = $label;
|
||||
|
||||
return $this;
|
||||
return $this->ordering;
|
||||
}
|
||||
|
||||
public function getShareHousehold(): bool
|
||||
@@ -69,18 +78,6 @@ class Position
|
||||
return $this->shareHouseHold;
|
||||
}
|
||||
|
||||
public function setShareHousehold(bool $shareHouseHold): self
|
||||
{
|
||||
$this->shareHouseHold = $shareHouseHold;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAllowHolder(): bool
|
||||
{
|
||||
return $this->allowHolder;
|
||||
}
|
||||
|
||||
public function isAllowHolder(): bool
|
||||
{
|
||||
return $this->getAllowHolder();
|
||||
@@ -93,9 +90,11 @@ class Position
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOrdering(): float
|
||||
public function setLabel(array $label): self
|
||||
{
|
||||
return $this->ordering;
|
||||
$this->label = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setOrdering(float $ordering): self
|
||||
@@ -104,4 +103,11 @@ class Position
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setShareHousehold(bool $shareHouseHold): self
|
||||
{
|
||||
$this->shareHouseHold = $shareHouseHold;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +1,10 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity;
|
||||
@@ -23,18 +12,18 @@ namespace Chill\PersonBundle\Entity;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* MaritalStatus
|
||||
* MaritalStatus.
|
||||
*
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_person_marital_status")
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class MaritalStatus
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Id()
|
||||
* @ORM\Id
|
||||
* @ORM\Column(type="string", length=7)
|
||||
*/
|
||||
private ?string $id;
|
||||
@@ -46,9 +35,7 @@ class MaritalStatus
|
||||
private array $name;
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return string
|
||||
* Get id.
|
||||
*/
|
||||
public function getId(): string
|
||||
{
|
||||
@@ -56,21 +43,32 @@ class MaritalStatus
|
||||
}
|
||||
|
||||
/**
|
||||
* Set id
|
||||
* Get name.
|
||||
*
|
||||
* @return string array
|
||||
*/
|
||||
public function getName(): array
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set id.
|
||||
*
|
||||
* @param string $id
|
||||
* @return MaritalStatus
|
||||
*/
|
||||
public function setId(string $id): self
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name
|
||||
* Set name.
|
||||
*
|
||||
* @param string array $name
|
||||
*
|
||||
* @return MaritalStatus
|
||||
*/
|
||||
public function setName(array $name): self
|
||||
@@ -79,14 +77,4 @@ class MaritalStatus
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return string array
|
||||
*/
|
||||
public function getName(): array
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity\Person;
|
||||
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
@@ -13,13 +21,18 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
* The computation is optimized on database side.
|
||||
*
|
||||
* The validFrom and validTo properties are the intersection of
|
||||
* household membership and address validity. See @link{PersonHouseholdAddress}
|
||||
* household membership and address validity. See @see{PersonHouseholdAddress}
|
||||
*
|
||||
* @ORM\Entity(readOnly=true)
|
||||
* @ORM\Table("view_chill_person_current_address")
|
||||
*/
|
||||
class PersonCurrentAddress
|
||||
{
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity=Address::class)
|
||||
*/
|
||||
protected Address $address;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\OneToOne(targetEntity=Person::class, inversedBy="currentPersonAddress")
|
||||
@@ -27,55 +40,40 @@ class PersonCurrentAddress
|
||||
*/
|
||||
protected Person $person;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity=Address::class)
|
||||
*/
|
||||
protected Address $address;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="valid_from", type="date_immutable")
|
||||
*/
|
||||
protected \DateTimeImmutable $validFrom;
|
||||
protected DateTimeImmutable $validFrom;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="valid_to", type="date_immutable")
|
||||
*/
|
||||
protected ?\DateTimeImmutable $validTo;
|
||||
protected ?DateTimeImmutable $validTo;
|
||||
|
||||
public function getAddress(): Address
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Person
|
||||
*/
|
||||
public function getPerson(): Person
|
||||
{
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Address
|
||||
*/
|
||||
public function getAddress(): Address
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* This date is the intersection of household membership
|
||||
* and address validity
|
||||
*
|
||||
* @return \DateTimeImmutable
|
||||
* and address validity.
|
||||
*/
|
||||
public function getValidFrom(): \DateTimeImmutable
|
||||
public function getValidFrom(): DateTimeImmutable
|
||||
{
|
||||
return $this->validFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* This date is the intersection of household membership
|
||||
* and address validity
|
||||
*
|
||||
* @return \DateTimeImmutable|null
|
||||
* and address validity.
|
||||
*/
|
||||
public function getValidTo(): ?\DateTimeImmutable
|
||||
public function getValidTo(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->validTo;
|
||||
}
|
||||
|
@@ -1,11 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* PersonAltName
|
||||
* PersonAltName.
|
||||
*
|
||||
* @ORM\Table(name="chill_person_alt_name")
|
||||
* @ORM\Entity
|
||||
@@ -13,7 +20,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
class PersonAltName
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
@@ -34,18 +41,17 @@ class PersonAltName
|
||||
* @ORM\Column(name="label", type="text")
|
||||
*/
|
||||
private $label;
|
||||
|
||||
|
||||
/**
|
||||
* @var Person
|
||||
*
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\PersonBundle\Entity\Person",
|
||||
* inversedBy="altNames"
|
||||
* targetEntity="Chill\PersonBundle\Entity\Person",
|
||||
* inversedBy="altNames"
|
||||
* )
|
||||
*/
|
||||
private $person;
|
||||
|
||||
|
||||
/**
|
||||
* Get id.
|
||||
*
|
||||
@@ -56,6 +62,31 @@ class PersonAltName
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get key.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getKey()
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get label.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
public function getPerson(): Person
|
||||
{
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set key.
|
||||
*
|
||||
@@ -70,16 +101,6 @@ class PersonAltName
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get key.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getKey()
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set label.
|
||||
*
|
||||
@@ -95,31 +116,12 @@ class PersonAltName
|
||||
}
|
||||
|
||||
/**
|
||||
* Get label.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Person
|
||||
*/
|
||||
public function getPerson(): Person
|
||||
{
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Person|null $person
|
||||
* @return $this
|
||||
*/
|
||||
public function setPerson(?Person $person = null)
|
||||
{
|
||||
$this->person = $person;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* PersonNotDuplicate
|
||||
* PersonNotDuplicate.
|
||||
*
|
||||
* @ORM\Table(name="chill_person_not_duplicate")
|
||||
* @ORM\Entity
|
||||
@@ -14,8 +22,15 @@ use Chill\MainBundle\Entity\User;
|
||||
class PersonNotDuplicate
|
||||
{
|
||||
/**
|
||||
* The person's id
|
||||
* @var integer
|
||||
* @var DateTime
|
||||
* @ORM\Column(type="datetime")
|
||||
*/
|
||||
private $date;
|
||||
|
||||
/**
|
||||
* The person's id.
|
||||
*
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
@@ -37,12 +52,6 @@ class PersonNotDuplicate
|
||||
*/
|
||||
private $person2;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
* @ORM\Column(type="datetime")
|
||||
*/
|
||||
private $date;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*
|
||||
@@ -52,37 +61,7 @@ class PersonNotDuplicate
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->date = new \DateTime();
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getPerson1()
|
||||
{
|
||||
return $this->person1;
|
||||
}
|
||||
|
||||
public function setPerson1(Person $person1)
|
||||
{
|
||||
$this->person1 = $person1;
|
||||
}
|
||||
|
||||
public function getPerson2()
|
||||
{
|
||||
return $this->person2;
|
||||
}
|
||||
|
||||
public function setPerson2(Person $person2)
|
||||
{
|
||||
$this->person2 = $person2;
|
||||
$this->date = new DateTime();
|
||||
}
|
||||
|
||||
public function getDate()
|
||||
@@ -90,9 +69,19 @@ class PersonNotDuplicate
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function setDate(\DateTime $date)
|
||||
public function getId()
|
||||
{
|
||||
$this->date = $date;
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getPerson1()
|
||||
{
|
||||
return $this->person1;
|
||||
}
|
||||
|
||||
public function getPerson2()
|
||||
{
|
||||
return $this->person2;
|
||||
}
|
||||
|
||||
public function getUser()
|
||||
@@ -100,6 +89,26 @@ class PersonNotDuplicate
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setDate(DateTime $date)
|
||||
{
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function setPerson1(Person $person1)
|
||||
{
|
||||
$this->person1 = $person1;
|
||||
}
|
||||
|
||||
public function setPerson2(Person $person2)
|
||||
{
|
||||
$this->person2 = $person2;
|
||||
}
|
||||
|
||||
public function setUser(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
|
@@ -1,21 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity;
|
||||
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Person Phones
|
||||
* Person Phones.
|
||||
*
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_person_phone",
|
||||
* indexes={
|
||||
* @ORM\Index(name="phonenumber", columns={"phonenumber"})
|
||||
* })
|
||||
* @ORM\Index(name="phonenumber", columns={"phonenumber"})
|
||||
* })
|
||||
*/
|
||||
class PersonPhone
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=false)
|
||||
*/
|
||||
private DateTime $date;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*/
|
||||
private ?string $description = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
@@ -25,35 +42,35 @@ class PersonPhone
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\PersonBundle\Entity\Person",
|
||||
* inversedBy="otherPhoneNumbers"
|
||||
* targetEntity="Chill\PersonBundle\Entity\Person",
|
||||
* inversedBy="otherPhoneNumbers"
|
||||
* )
|
||||
*/
|
||||
private Person $person;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", length=40, nullable=true)
|
||||
*/
|
||||
private ?string $type;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", length=40, nullable=false)
|
||||
*/
|
||||
private string $phonenumber = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
* @ORM\Column(type="text", length=40, nullable=true)
|
||||
*/
|
||||
private ?string $description = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=false)
|
||||
*/
|
||||
private \DateTime $date;
|
||||
private ?string $type;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->date = new \DateTime();
|
||||
$this->date = new DateTime();
|
||||
}
|
||||
|
||||
public function getDate(): DateTime
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function getId(): int
|
||||
@@ -66,9 +83,9 @@ class PersonPhone
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
public function setPerson(Person $person): void
|
||||
public function getPhonenumber(): string
|
||||
{
|
||||
$this->person = $person;
|
||||
return $this->phonenumber;
|
||||
}
|
||||
|
||||
public function getType(): string
|
||||
@@ -76,24 +93,14 @@ class PersonPhone
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType(string $type): void
|
||||
public function isEmpty(): bool
|
||||
{
|
||||
$this->type = $type;
|
||||
return empty($this->getDescription()) && empty($this->getPhonenumber());
|
||||
}
|
||||
|
||||
public function getPhonenumber(): string
|
||||
public function setDate(DateTime $date): void
|
||||
{
|
||||
return $this->phonenumber;
|
||||
}
|
||||
|
||||
public function setPhonenumber(string $phonenumber): void
|
||||
{
|
||||
$this->phonenumber = $phonenumber;
|
||||
}
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
public function setDescription(?string $description): void
|
||||
@@ -101,18 +108,18 @@ class PersonPhone
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
public function getDate(): \DateTime
|
||||
public function setPerson(Person $person): void
|
||||
{
|
||||
return $this->date;
|
||||
$this->person = $person;
|
||||
}
|
||||
|
||||
public function setDate(\DateTime $date): void
|
||||
public function setPhonenumber(string $phonenumber): void
|
||||
{
|
||||
$this->date = $date;
|
||||
$this->phonenumber = $phonenumber;
|
||||
}
|
||||
|
||||
public function isEmpty(): bool
|
||||
public function setType(string $type): void
|
||||
{
|
||||
return empty($this->getDescription()) && empty($this->getPhonenumber());
|
||||
$this->type = $type;
|
||||
}
|
||||
}
|
||||
|
@@ -1,17 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity\Relationships;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\ORM\Mapping\DiscriminatorColumn;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_person_relations")
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "relation"=Relation::class
|
||||
* "relation": Relation::class
|
||||
* })
|
||||
*/
|
||||
class Relation
|
||||
@@ -25,10 +31,10 @@ class Relation
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json", nullable=true)
|
||||
* @ORM\Column(type="boolean", nullable=true)
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private array $title = [];
|
||||
private bool $isActive = true;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json", nullable=true)
|
||||
@@ -37,33 +43,38 @@ class Relation
|
||||
private array $reverseTitle = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", nullable=true)
|
||||
* @ORM\Column(type="json", nullable=true)
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private bool $isActive = true;
|
||||
private array $title = [];
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getIsActive(): bool
|
||||
{
|
||||
return $this->isActive;
|
||||
}
|
||||
|
||||
public function getReverseTitle(): ?array
|
||||
{
|
||||
return $this->reverseTitle;
|
||||
}
|
||||
|
||||
public function getTitle(): ?array
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle(?array $title): self
|
||||
public function setIsActive(?bool $isActive): self
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->isActive = $isActive;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getReverseTitle(): ?array
|
||||
{
|
||||
return $this->reverseTitle;
|
||||
}
|
||||
|
||||
public function setReverseTitle(?array $reverseTitle): self
|
||||
{
|
||||
$this->reverseTitle = $reverseTitle;
|
||||
@@ -71,14 +82,9 @@ class Relation
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIsActive(): bool
|
||||
public function setTitle(?array $title): self
|
||||
{
|
||||
return $this->isActive;
|
||||
}
|
||||
|
||||
public function setIsActive(?bool $isActive): self
|
||||
{
|
||||
$this->isActive = $isActive;
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@@ -1,30 +1,55 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity\Relationships;
|
||||
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\Relationships\Relation;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Doctrine\ORM\Mapping\DiscriminatorColumn;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_person_relationships")
|
||||
* @DiscriminatorColumn(name="relation_id", type="integer")
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "relationship"=Relationship::class
|
||||
* "relationship": Relationship::class
|
||||
* })
|
||||
*
|
||||
*/
|
||||
class Relationship implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable")
|
||||
*/
|
||||
private ?DateTimeImmutable $createdAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private ?User $createdBy = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
* @Assert\NotNull
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private ?Person $fromPerson = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
@@ -33,65 +58,50 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
* @Assert\NotNull()
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private ?Person $fromPerson = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
* @Assert\NotNull()
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private ?Person $toPerson = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Relation::class)
|
||||
* @ORM\JoinColumn(nullable=false, name="relation_id", referencedColumnName="id")
|
||||
* @Assert\NotNull()
|
||||
* @Assert\NotNull
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private ?Relation $relation = null;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
* @Assert\Type(
|
||||
* type="bool",
|
||||
* message="This must be of type boolean"
|
||||
* type="bool",
|
||||
* message="This must be of type boolean"
|
||||
* )
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private bool $reverse;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
* @Assert\NotNull
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private ?User $createdBy = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable")
|
||||
*/
|
||||
private ?DateTimeImmutable $createdAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*/
|
||||
private ?User $updatedBy = null;
|
||||
private ?Person $toPerson = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable", nullable=true)
|
||||
*/
|
||||
private ?DateTimeImmutable $updatedAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*/
|
||||
private ?User $updatedBy = null;
|
||||
|
||||
public function getId(): ?int
|
||||
public function getCreatedAt(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->id;
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function getCreatedBy(): ?User
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
public function getFromPerson(): ?Person
|
||||
@@ -99,23 +109,14 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->fromPerson;
|
||||
}
|
||||
|
||||
public function setFromPerson(?Person $fromPerson): self
|
||||
public function getId(): ?int
|
||||
{
|
||||
$this->fromPerson = $fromPerson;
|
||||
|
||||
return $this;
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getToPerson(): ?Person
|
||||
public function getRelation(): ?Relation
|
||||
{
|
||||
return $this->toPerson;
|
||||
}
|
||||
|
||||
public function setToPerson(?Person $toPerson): self
|
||||
{
|
||||
$this->toPerson = $toPerson;
|
||||
|
||||
return $this;
|
||||
return $this->relation;
|
||||
}
|
||||
|
||||
public function getReverse(): ?bool
|
||||
@@ -123,16 +124,26 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->reverse;
|
||||
}
|
||||
|
||||
public function setReverse(bool $reverse): self
|
||||
public function getToPerson(): ?Person
|
||||
{
|
||||
$this->reverse = $reverse;
|
||||
|
||||
return $this;
|
||||
return $this->toPerson;
|
||||
}
|
||||
|
||||
public function getCreatedBy(): ?User
|
||||
public function getUpdatedAt(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->createdBy;
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
public function getUpdatedBy(): ?User
|
||||
{
|
||||
return $this->updatedBy;
|
||||
}
|
||||
|
||||
public function setCreatedAt(DateTimeInterface $createdAt): self
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCreatedBy(?User $user): self
|
||||
@@ -142,51 +153,45 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): ?\DateTimeImmutable
|
||||
public function setFromPerson(?Person $fromPerson): self
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function setCreatedAt(\DateTimeInterface $createdAt): self
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
$this->fromPerson = $fromPerson;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUpdatedBy(): ?User
|
||||
{
|
||||
return $this->updatedBy;
|
||||
}
|
||||
|
||||
public function setUpdatedBy(?User $updatedBy): self
|
||||
{
|
||||
$this->updatedBy = $updatedBy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRelation(): ?Relation
|
||||
{
|
||||
return $this->relation;
|
||||
}
|
||||
|
||||
public function setRelation(?Relation $relation): self
|
||||
{
|
||||
$this->relation = $relation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
public function setReverse(bool $reverse): self
|
||||
{
|
||||
$this->reverse = $reverse;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setToPerson(?Person $toPerson): self
|
||||
{
|
||||
$this->toPerson = $toPerson;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(?DateTimeInterface $updatedAt): self
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatedBy(?User $updatedBy): self
|
||||
{
|
||||
$this->updatedBy = $updatedBy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity\SocialWork;
|
||||
|
||||
use DateInterval;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
@@ -9,11 +17,17 @@ use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_person_social_work_evaluation")
|
||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "social_work_evaluation"=Evaluation::class
|
||||
* })
|
||||
* "social_work_evaluation": Evaluation::class
|
||||
* })
|
||||
*/
|
||||
class Evaluation
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="dateinterval", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private $delay;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
@@ -22,18 +36,6 @@ class Evaluation
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private $title = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="dateinterval", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private $delay;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="dateinterval", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
@@ -48,56 +50,62 @@ class Evaluation
|
||||
*/
|
||||
private $socialAction;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private $title = [];
|
||||
|
||||
public function getDelay(): ?DateInterval
|
||||
{
|
||||
return $this->delay;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getNotificationDelay(): ?DateInterval
|
||||
{
|
||||
return $this->notificationDelay;
|
||||
}
|
||||
|
||||
public function getSocialAction(): ?SocialAction
|
||||
{
|
||||
return $this->socialAction;
|
||||
}
|
||||
|
||||
public function getTitle(): array
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle(array $title): self
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDelay(): ?\DateInterval
|
||||
{
|
||||
return $this->delay;
|
||||
}
|
||||
|
||||
public function setDelay(\DateInterval $delay): self
|
||||
public function setDelay(DateInterval $delay): self
|
||||
{
|
||||
$this->delay = $delay;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getNotificationDelay(): ?\DateInterval
|
||||
{
|
||||
return $this->notificationDelay;
|
||||
}
|
||||
|
||||
public function setNotificationDelay(\DateInterval $notificationDelay): self
|
||||
public function setNotificationDelay(DateInterval $notificationDelay): self
|
||||
{
|
||||
$this->notificationDelay = $notificationDelay;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSocialAction(): ?SocialAction
|
||||
{
|
||||
return $this->socialAction;
|
||||
}
|
||||
|
||||
public function setSocialAction(?SocialAction $socialAction): self
|
||||
{
|
||||
$this->socialAction = $socialAction;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTitle(array $title): self
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity\SocialWork;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
@@ -11,14 +19,19 @@ use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_person_social_work_goal")
|
||||
* @Serializer\DiscriminatorMap(
|
||||
* typeProperty="type",
|
||||
* mapping={
|
||||
* "social_work_goal":Goal::class
|
||||
* }
|
||||
* )
|
||||
* typeProperty="type",
|
||||
* mapping={
|
||||
* "social_work_goal": Goal::class
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class Goal
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
private $desactivationDate;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
@@ -28,15 +41,10 @@ class Goal
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
* @Serializer\Groups({"read"})
|
||||
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="goals")
|
||||
* @ORM\JoinTable(name="chill_person_social_work_goal_result")
|
||||
*/
|
||||
private $title = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
private $desactivationDate;
|
||||
private $results;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity=SocialAction::class, mappedBy="goals")
|
||||
@@ -44,10 +52,10 @@ class Goal
|
||||
private $socialActions;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="goals")
|
||||
* @ORM\JoinTable(name="chill_person_social_work_goal_result")
|
||||
* @ORM\Column(type="json")
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private $results;
|
||||
private $title = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -55,67 +63,6 @@ class Goal
|
||||
$this->results = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getTitle(): array
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle(array $title): self
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDesactivationDate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->desactivationDate;
|
||||
}
|
||||
|
||||
public function setDesactivationDate(?\DateTimeInterface $desactivationDate): self
|
||||
{
|
||||
$this->desactivationDate = $desactivationDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|SocialAction[]
|
||||
*/
|
||||
public function getSocialActions(): Collection
|
||||
{
|
||||
return $this->socialActions;
|
||||
}
|
||||
|
||||
public function addSocialAction(SocialAction $socialAction): self
|
||||
{
|
||||
if (!$this->socialActions->contains($socialAction)) {
|
||||
$this->socialActions[] = $socialAction;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeSocialAction(SocialAction $socialAction): self
|
||||
{
|
||||
$this->socialActions->removeElement($socialAction);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Result[]
|
||||
*/
|
||||
public function getResults(): Collection
|
||||
{
|
||||
return $this->results;
|
||||
}
|
||||
|
||||
public function addResult(Result $result): self
|
||||
{
|
||||
if (!$this->results->contains($result)) {
|
||||
@@ -125,10 +72,71 @@ class Goal
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addSocialAction(SocialAction $socialAction): self
|
||||
{
|
||||
if (!$this->socialActions->contains($socialAction)) {
|
||||
$this->socialActions[] = $socialAction;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDesactivationDate(): ?DateTimeInterface
|
||||
{
|
||||
return $this->desactivationDate;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Result[]
|
||||
*/
|
||||
public function getResults(): Collection
|
||||
{
|
||||
return $this->results;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|SocialAction[]
|
||||
*/
|
||||
public function getSocialActions(): Collection
|
||||
{
|
||||
return $this->socialActions;
|
||||
}
|
||||
|
||||
public function getTitle(): array
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function removeResult(Result $result): self
|
||||
{
|
||||
$this->results->removeElement($result);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeSocialAction(SocialAction $socialAction): self
|
||||
{
|
||||
$this->socialActions->removeElement($socialAction);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDesactivationDate(?DateTimeInterface $desactivationDate): self
|
||||
{
|
||||
$this->desactivationDate = $desactivationDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTitle(array $title): self
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity\SocialWork;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkGoal;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
@@ -13,14 +21,34 @@ use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_person_social_work_result")
|
||||
* @Serializer\DiscriminatorMap(
|
||||
* typeProperty="type",
|
||||
* mapping={
|
||||
* "social_work_result":Result::class
|
||||
* }
|
||||
* )
|
||||
* typeProperty="type",
|
||||
* mapping={
|
||||
* "social_work_result": Result::class
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class Result
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity=AccompanyingPeriodWorkGoal::class, mappedBy="results")
|
||||
*/
|
||||
private $accompanyingPeriodWorkGoals;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity=AccompanyingPeriodWork::class, mappedBy="results")
|
||||
*/
|
||||
private $accompanyingPeriodWorks;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
private $desactivationDate;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity=Goal::class, mappedBy="results")
|
||||
*/
|
||||
private $goals;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
@@ -29,36 +57,16 @@ class Result
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private $title = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
private $desactivationDate;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity=SocialAction::class, mappedBy="results")
|
||||
*/
|
||||
private $socialActions;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity=Goal::class, mappedBy="results")
|
||||
* @ORM\Column(type="json")
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private $goals;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity=AccompanyingPeriodWork::class, mappedBy="results")
|
||||
*/
|
||||
private $accompanyingPeriodWorks;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity=AccompanyingPeriodWorkGoal::class, mappedBy="results")
|
||||
*/
|
||||
private $accompanyingPeriodWorkGoals;
|
||||
private $title = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -68,91 +76,6 @@ class Result
|
||||
$this->accompanyingPeriodWorkGoals = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getTitle(): array
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle(array $title): self
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDesactivationDate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->desactivationDate;
|
||||
}
|
||||
|
||||
public function setDesactivationDate(?\DateTimeInterface $desactivationDate): self
|
||||
{
|
||||
$this->desactivationDate = $desactivationDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|SocialAction[]
|
||||
*/
|
||||
public function getSocialActions(): Collection
|
||||
{
|
||||
return $this->socialActions;
|
||||
}
|
||||
|
||||
public function addSocialAction(SocialAction $socialAction): self
|
||||
{
|
||||
if (!$this->socialActions->contains($socialAction)) {
|
||||
$this->socialActions[] = $socialAction;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeSocialAction(SocialAction $socialAction): self
|
||||
{
|
||||
$this->socialActions->removeElement($socialAction);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Goal[]
|
||||
*/
|
||||
public function getGoals(): Collection
|
||||
{
|
||||
return $this->goals;
|
||||
}
|
||||
|
||||
public function addGoal(Goal $goal): self
|
||||
{
|
||||
if (!$this->goals->contains($goal)) {
|
||||
$this->goals[] = $goal;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeGoal(Goal $goal): self
|
||||
{
|
||||
$this->goals->removeElement($goal);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|AccompanyingPeriodWork[]
|
||||
*/
|
||||
public function getAccompanyingPeriodWorks(): Collection
|
||||
{
|
||||
return $this->accompanyingPeriodWorks;
|
||||
}
|
||||
|
||||
public function addAccompanyingPeriodWork(AccompanyingPeriodWork $accompanyingPeriod): self
|
||||
{
|
||||
if (!$this->accompanyingPeriodWorks->contains($accompanyingPeriod)) {
|
||||
@@ -162,26 +85,83 @@ class Result
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeAccompanyingPeriodWork(AccompanyingPeriodWork $accompanyingPeriod): self
|
||||
public function addAccompanyingPeriodWorkGoal(AccompanyingPeriodWorkGoal $accompanyingPeriodWorkGoal): self
|
||||
{
|
||||
$this->accompanyingPeriodWorks->removeElement($accompanyingPeriod);
|
||||
if (!$this->accompanyingPeriodWorkGoals->contains($accompanyingPeriodWorkGoal)) {
|
||||
$this->accompanyingPeriodWorkGoals[] = $accompanyingPeriodWorkGoal;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addGoal(Goal $goal): self
|
||||
{
|
||||
if (!$this->goals->contains($goal)) {
|
||||
$this->goals[] = $goal;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addSocialAction(SocialAction $socialAction): self
|
||||
{
|
||||
if (!$this->socialActions->contains($socialAction)) {
|
||||
$this->socialActions[] = $socialAction;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|AccompanyingPeriodWorkGoal[]
|
||||
* @return AccompanyingPeriodWorkGoal[]|Collection
|
||||
*/
|
||||
public function getAccompanyingPeriodWorkGoals(): Collection
|
||||
{
|
||||
return $this->accompanyingPeriodWorkGoals;
|
||||
}
|
||||
|
||||
public function addAccompanyingPeriodWorkGoal(AccompanyingPeriodWorkGoal $accompanyingPeriodWorkGoal): self
|
||||
/**
|
||||
* @return AccompanyingPeriodWork[]|Collection
|
||||
*/
|
||||
public function getAccompanyingPeriodWorks(): Collection
|
||||
{
|
||||
if (!$this->accompanyingPeriodWorkGoals->contains($accompanyingPeriodWorkGoal)) {
|
||||
$this->accompanyingPeriodWorkGoals[] = $accompanyingPeriodWorkGoal;
|
||||
}
|
||||
return $this->accompanyingPeriodWorks;
|
||||
}
|
||||
|
||||
public function getDesactivationDate(): ?DateTimeInterface
|
||||
{
|
||||
return $this->desactivationDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Goal[]
|
||||
*/
|
||||
public function getGoals(): Collection
|
||||
{
|
||||
return $this->goals;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|SocialAction[]
|
||||
*/
|
||||
public function getSocialActions(): Collection
|
||||
{
|
||||
return $this->socialActions;
|
||||
}
|
||||
|
||||
public function getTitle(): array
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function removeAccompanyingPeriodWork(AccompanyingPeriodWork $accompanyingPeriod): self
|
||||
{
|
||||
$this->accompanyingPeriodWorks->removeElement($accompanyingPeriod);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -192,4 +172,32 @@ class Result
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeGoal(Goal $goal): self
|
||||
{
|
||||
$this->goals->removeElement($goal);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeSocialAction(SocialAction $socialAction): self
|
||||
{
|
||||
$this->socialActions->removeElement($socialAction);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDesactivationDate(?DateTimeInterface $desactivationDate): self
|
||||
{
|
||||
$this->desactivationDate = $desactivationDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTitle(array $title): self
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity\SocialWork;
|
||||
|
||||
use DateInterval;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
@@ -11,14 +20,43 @@ use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_person_social_action")
|
||||
* @Serializer\DiscriminatorMap(
|
||||
* typeProperty="type",
|
||||
* mapping={
|
||||
* "social_work_social_action":SocialAction::class
|
||||
* }
|
||||
* )
|
||||
* typeProperty="type",
|
||||
* mapping={
|
||||
* "social_work_social_action": SocialAction::class
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class SocialAction
|
||||
{
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity=SocialAction::class, mappedBy="parent")
|
||||
*/
|
||||
private $children;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="dateinterval", nullable=true)
|
||||
*/
|
||||
private $defaultNotificationDelay;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
private $desactivationDate;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=Evaluation::class,
|
||||
* mappedBy="socialAction"
|
||||
* )
|
||||
*/
|
||||
private Collection $evaluations;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity=Goal::class, inversedBy="socialActions")
|
||||
* @ORM\JoinTable(name="chill_person_social_action_goal")
|
||||
*/
|
||||
private $goals;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
@@ -26,11 +64,6 @@ class SocialAction
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
private $desactivationDate;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=SocialIssue::class, inversedBy="socialActions")
|
||||
*/
|
||||
@@ -41,27 +74,6 @@ class SocialAction
|
||||
*/
|
||||
private $parent;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity=SocialAction::class, mappedBy="parent")
|
||||
*/
|
||||
private $children;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="dateinterval", nullable=true)
|
||||
*/
|
||||
private $defaultNotificationDelay;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
*/
|
||||
private $title = [];
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity=Goal::class, inversedBy="socialActions")
|
||||
* @ORM\JoinTable(name="chill_person_social_action_goal")
|
||||
*/
|
||||
private $goals;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="socialActions")
|
||||
* @ORM\JoinTable(name="chill_person_social_action_result")
|
||||
@@ -69,13 +81,9 @@ class SocialAction
|
||||
private $results;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=Evaluation::class,
|
||||
* mappedBy="socialAction"
|
||||
* )
|
||||
* @ORM\Column(type="json")
|
||||
*/
|
||||
private Collection $evaluations;
|
||||
private $title = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -84,60 +92,6 @@ class SocialAction
|
||||
$this->results = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getDesactivationDate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->desactivationDate;
|
||||
}
|
||||
|
||||
public function setDesactivationDate(?\DateTimeInterface $desactivationDate): self
|
||||
{
|
||||
$this->desactivationDate = $desactivationDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIssue(): ?SocialIssue
|
||||
{
|
||||
return $this->issue;
|
||||
}
|
||||
|
||||
public function setIssue(?SocialIssue $issue): self
|
||||
{
|
||||
$this->issue = $issue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getParent(): ?self
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
public function hasParent(): bool
|
||||
{
|
||||
return $this->getParent() instanceof self;
|
||||
}
|
||||
|
||||
public function setParent(?self $parent): self
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|self[]
|
||||
*/
|
||||
public function getChildren(): Collection
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
public function addChild(self $child): self
|
||||
{
|
||||
if (!$this->children->contains($child)) {
|
||||
@@ -148,18 +102,42 @@ class SocialAction
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeChild(self $child): self
|
||||
public function addGoal(Goal $goal): self
|
||||
{
|
||||
if ($this->children->removeElement($child)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($child->getParent() === $this) {
|
||||
$child->setParent(null);
|
||||
}
|
||||
if (!$this->goals->contains($goal)) {
|
||||
$this->goals[] = $goal;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addResult(Result $result): self
|
||||
{
|
||||
if (!$this->results->contains($result)) {
|
||||
$this->results[] = $result;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|self[]
|
||||
*/
|
||||
public function getChildren(): Collection
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
public function getDefaultNotificationDelay(): ?DateInterval
|
||||
{
|
||||
return $this->defaultNotificationDelay;
|
||||
}
|
||||
|
||||
public function getDesactivationDate(): ?DateTimeInterface
|
||||
{
|
||||
return $this->desactivationDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|self[] All the descendants (children, children of children, ...)
|
||||
*/
|
||||
@@ -168,10 +146,11 @@ class SocialAction
|
||||
$descendants = new ArrayCollection();
|
||||
|
||||
foreach ($this->getChildren() as $child) {
|
||||
if(! $descendants->contains($child)) {
|
||||
if (!$descendants->contains($child)) {
|
||||
$descendants->add($child);
|
||||
foreach($child->getDescendants() as $descendantsOfChild) {
|
||||
if(! $descendants->contains($descendantsOfChild)) {
|
||||
|
||||
foreach ($child->getDescendants() as $descendantsOfChild) {
|
||||
if (!$descendants->contains($descendantsOfChild)) {
|
||||
$descendants->add($descendantsOfChild);
|
||||
}
|
||||
}
|
||||
@@ -188,35 +167,16 @@ class SocialAction
|
||||
{
|
||||
$descendants = $this->getDescendants();
|
||||
|
||||
if(! $descendants->contains($this)) {
|
||||
if (!$descendants->contains($this)) {
|
||||
$descendants->add($this);
|
||||
}
|
||||
|
||||
return $descendants;
|
||||
}
|
||||
|
||||
public function getDefaultNotificationDelay(): ?\DateInterval
|
||||
public function getEvaluations(): Collection
|
||||
{
|
||||
return $this->defaultNotificationDelay;
|
||||
}
|
||||
|
||||
public function setDefaultNotificationDelay(\DateInterval $defaultNotificationDelay): self
|
||||
{
|
||||
$this->defaultNotificationDelay = $defaultNotificationDelay;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle(): array
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle(array $title): self
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
return $this->evaluations;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,10 +187,46 @@ class SocialAction
|
||||
return $this->goals;
|
||||
}
|
||||
|
||||
public function addGoal(Goal $goal): self
|
||||
public function getId(): ?int
|
||||
{
|
||||
if (!$this->goals->contains($goal)) {
|
||||
$this->goals[] = $goal;
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getIssue(): ?SocialIssue
|
||||
{
|
||||
return $this->issue;
|
||||
}
|
||||
|
||||
public function getParent(): ?self
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Result[]
|
||||
*/
|
||||
public function getResults(): Collection
|
||||
{
|
||||
return $this->results;
|
||||
}
|
||||
|
||||
public function getTitle(): array
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function hasParent(): bool
|
||||
{
|
||||
return $this->getParent() instanceof self;
|
||||
}
|
||||
|
||||
public function removeChild(self $child): self
|
||||
{
|
||||
if ($this->children->removeElement($child)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($child->getParent() === $this) {
|
||||
$child->setParent(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -243,23 +239,6 @@ class SocialAction
|
||||
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);
|
||||
@@ -267,11 +246,38 @@ class SocialAction
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getEvaluations(): Collection
|
||||
public function setDefaultNotificationDelay(DateInterval $defaultNotificationDelay): self
|
||||
{
|
||||
return $this->evaluations;
|
||||
$this->defaultNotificationDelay = $defaultNotificationDelay;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDesactivationDate(?DateTimeInterface $desactivationDate): self
|
||||
{
|
||||
$this->desactivationDate = $desactivationDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setIssue(?SocialIssue $issue): self
|
||||
{
|
||||
$this->issue = $issue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setParent(?self $parent): self
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTitle(array $title): self
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity\SocialWork;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_person_social_issue")
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "social_issue"=SocialIssue::class
|
||||
* "social_issue": SocialIssue::class
|
||||
* })
|
||||
*/
|
||||
class SocialIssue
|
||||
{
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity=SocialIssue::class, mappedBy="parent")
|
||||
*/
|
||||
private $children;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
private $desactivationDate;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
@@ -29,14 +48,9 @@ class SocialIssue
|
||||
private $parent;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity=SocialIssue::class, mappedBy="parent")
|
||||
* @ORM\OneToMany(targetEntity=SocialAction::class, mappedBy="issue")
|
||||
*/
|
||||
private $children;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
private $desactivationDate;
|
||||
private $socialActions;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
@@ -44,47 +58,12 @@ class SocialIssue
|
||||
*/
|
||||
private $title = [];
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity=SocialAction::class, mappedBy="issue")
|
||||
*/
|
||||
private $socialActions;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->children = new ArrayCollection();
|
||||
$this->socialActions = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getParent(): ?self
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
public function hasParent(): bool
|
||||
{
|
||||
return $this->parent !== null;
|
||||
}
|
||||
|
||||
public function setParent(?self $parent): self
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|self[]
|
||||
*/
|
||||
public function getChildren(): Collection
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
public function addChild(self $child): self
|
||||
{
|
||||
if (!$this->children->contains($child)) {
|
||||
@@ -95,18 +74,64 @@ class SocialIssue
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeChild(self $child): self
|
||||
public function addSocialAction(SocialAction $socialAction): self
|
||||
{
|
||||
if ($this->children->removeElement($child)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($child->getParent() === $this) {
|
||||
$child->setParent(null);
|
||||
}
|
||||
if (!$this->socialActions->contains($socialAction)) {
|
||||
$this->socialActions[] = $socialAction;
|
||||
$socialAction->setSocialIssue($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* In a SocialIssues's collection, find the elements which are an ancestor of
|
||||
* other elements.
|
||||
*
|
||||
* Removing those elements of the Collection (which is not done by this method)
|
||||
* will ensure that only the most descendent elements are present in the collection,
|
||||
* (any ancestor of another element are present).
|
||||
*
|
||||
* @param Collection|SocialIssue[] $socialIssues
|
||||
*
|
||||
* @return Collection|SocialIssue[]
|
||||
*/
|
||||
public static function findAncestorSocialIssues(Collection $socialIssues): Collection
|
||||
{
|
||||
$ancestors = new ArrayCollection();
|
||||
|
||||
foreach ($socialIssues as $candidateChild) {
|
||||
if ($ancestors->contains($candidateChild)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($socialIssues as $candidateParent) {
|
||||
if ($ancestors->contains($candidateParent)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($candidateChild->isDescendantOf($candidateParent)) {
|
||||
$ancestors->add($candidateParent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ancestors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|self[]
|
||||
*/
|
||||
public function getChildren(): Collection
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
public function getDesactivationDate(): ?DateTimeInterface
|
||||
{
|
||||
return $this->desactivationDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|self[] All the descendants (children, children of children, ...)
|
||||
*/
|
||||
@@ -115,10 +140,11 @@ class SocialIssue
|
||||
$descendants = new ArrayCollection();
|
||||
|
||||
foreach ($this->getChildren() as $child) {
|
||||
if(! $descendants->contains($child)) {
|
||||
if (!$descendants->contains($child)) {
|
||||
$descendants->add($child);
|
||||
foreach($child->getDescendants() as $descendantsOfChild) {
|
||||
if(! $descendants->contains($descendantsOfChild)) {
|
||||
|
||||
foreach ($child->getDescendants() as $descendantsOfChild) {
|
||||
if (!$descendants->contains($descendantsOfChild)) {
|
||||
$descendants->add($descendantsOfChild);
|
||||
}
|
||||
}
|
||||
@@ -128,6 +154,24 @@ class SocialIssue
|
||||
return $descendants;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|SocialAction[] All the descendant social actions of the entity
|
||||
*/
|
||||
public function getDescendantsSocialActions(): Collection
|
||||
{
|
||||
$descendantsSocialActions = new ArrayCollection();
|
||||
|
||||
foreach ($this->getSocialActions() as $socialAction) {
|
||||
foreach ($socialAction->getDescendantsWithThis() as $descendant) {
|
||||
if (!$descendantsSocialActions->contains($descendant)) {
|
||||
$descendantsSocialActions->add($descendant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $descendantsSocialActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|self[] All the descendants with the current entity (this)
|
||||
*/
|
||||
@@ -135,36 +179,40 @@ class SocialIssue
|
||||
{
|
||||
$descendants = $this->getDescendants();
|
||||
|
||||
if(! $descendants->contains($this)) {
|
||||
if (!$descendants->contains($this)) {
|
||||
$descendants->add($this);
|
||||
}
|
||||
|
||||
return $descendants;
|
||||
}
|
||||
|
||||
|
||||
public function getDesactivationDate(): ?\DateTimeInterface
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->desactivationDate;
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setDesactivationDate(?\DateTimeInterface $desactivationDate): self
|
||||
public function getParent(): ?self
|
||||
{
|
||||
$this->desactivationDate = $desactivationDate;
|
||||
|
||||
return $this;
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
public function getTitle(): array
|
||||
/**
|
||||
* @return Collection|SocialAction[] All the descendant social actions of all
|
||||
* the descendants of the entity
|
||||
*/
|
||||
public function getRecursiveSocialActions(): Collection
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
$recursiveSocialActions = new ArrayCollection();
|
||||
|
||||
public function setTitle(array $title): self
|
||||
{
|
||||
$this->title = $title;
|
||||
foreach ($this->getDescendantsWithThis() as $socialIssue) {
|
||||
foreach ($socialIssue->getDescendantsSocialActions() as $descendant) {
|
||||
if (!$recursiveSocialActions->contains($descendant)) {
|
||||
$recursiveSocialActions->add($descendant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
return $recursiveSocialActions;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,11 +223,40 @@ class SocialIssue
|
||||
return $this->socialActions;
|
||||
}
|
||||
|
||||
public function addSocialAction(SocialAction $socialAction): self
|
||||
public function getTitle(): array
|
||||
{
|
||||
if (!$this->socialActions->contains($socialAction)) {
|
||||
$this->socialActions[] = $socialAction;
|
||||
$socialAction->setSocialIssue($this);
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function hasParent(): bool
|
||||
{
|
||||
return null !== $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive method which return true if the current $issue is a descendant
|
||||
* of the $issue given in parameter.
|
||||
*/
|
||||
public function isDescendantOf(SocialIssue $issue): bool
|
||||
{
|
||||
if (!$this->hasParent()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->getParent() === $issue) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->getParent()->isDescendantOf($issue);
|
||||
}
|
||||
|
||||
public function removeChild(self $child): self
|
||||
{
|
||||
if ($this->children->removeElement($child)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($child->getParent() === $this) {
|
||||
$child->setParent(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -197,93 +274,24 @@ class SocialIssue
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|SocialAction[] All the descendant social actions of the entity
|
||||
*/
|
||||
public function getDescendantsSocialActions(): Collection
|
||||
public function setDesactivationDate(?DateTimeInterface $desactivationDate): self
|
||||
{
|
||||
$descendantsSocialActions = new ArrayCollection();
|
||||
$this->desactivationDate = $desactivationDate;
|
||||
|
||||
foreach ($this->getSocialActions() as $socialAction) {
|
||||
foreach ($socialAction->getDescendantsWithThis() as $descendant) {
|
||||
if(! $descendantsSocialActions->contains($descendant)) {
|
||||
$descendantsSocialActions->add($descendant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $descendantsSocialActions;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|SocialAction[] All the descendant social actions of all
|
||||
* the descendants of the entity
|
||||
*/
|
||||
public function getRecursiveSocialActions(): Collection
|
||||
public function setParent(?self $parent): self
|
||||
{
|
||||
$recursiveSocialActions = new ArrayCollection();
|
||||
$this->parent = $parent;
|
||||
|
||||
foreach ($this->getDescendantsWithThis() as $socialIssue) {
|
||||
foreach ($socialIssue->getDescendantsSocialActions() as $descendant) {
|
||||
if(! $recursiveSocialActions->contains($descendant)) {
|
||||
$recursiveSocialActions->add($descendant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $recursiveSocialActions;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive method which return true if the current $issue is a descendant
|
||||
* of the $issue given in parameter.
|
||||
*
|
||||
* @param SocialIssue $issue
|
||||
* @return bool
|
||||
*/
|
||||
public function isDescendantOf(SocialIssue $issue): bool
|
||||
public function setTitle(array $title): self
|
||||
{
|
||||
if (!$this->hasParent()) {
|
||||
return false;
|
||||
}
|
||||
$this->title = $title;
|
||||
|
||||
if ($this->getParent() === $issue) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->getParent()->isDescendantOf($issue);
|
||||
}
|
||||
|
||||
/**
|
||||
* In a SocialIssues's collection, find the elements which are an ancestor of
|
||||
* other elements.
|
||||
*
|
||||
* Removing those elements of the Collection (which is not done by this method)
|
||||
* will ensure that only the most descendent elements are present in the collection,
|
||||
* (any ancestor of another element are present).
|
||||
*
|
||||
* @param Collection|SocialIssue[] $socialIssues
|
||||
* @return Collection|SocialIssue[]
|
||||
*/
|
||||
public static function findAncestorSocialIssues(Collection $socialIssues): Collection
|
||||
{
|
||||
$ancestors = new ArrayCollection();
|
||||
|
||||
foreach ($socialIssues as $candidateChild) {
|
||||
if ($ancestors->contains($candidateChild)) {
|
||||
continue;
|
||||
}
|
||||
foreach ($socialIssues as $candidateParent) {
|
||||
if ($ancestors->contains($candidateParent)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($candidateChild->isDescendantOf($candidateParent)) {
|
||||
$ancestors->add($candidateParent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ancestors;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user