cs: Fix code style (safe rules only).

This commit is contained in:
Pol Dellaiera
2021-11-23 14:06:38 +01:00
parent 149d7ce991
commit 8f96a1121d
1223 changed files with 65199 additions and 64625 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -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;
}
}