mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
255 lines
5.5 KiB
PHP
255 lines
5.5 KiB
PHP
<?php
|
|
|
|
namespace Chill\PersonBundle\Entity\SocialWork;
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
|
|
|
/**
|
|
* @ORM\Entity
|
|
* @ORM\Table(name="chill_person_social_action")
|
|
*/
|
|
class SocialAction
|
|
{
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\GeneratedValue
|
|
* @ORM\Column(type="integer")
|
|
*/
|
|
private $id;
|
|
|
|
/**
|
|
* @ORM\Column(type="datetime", nullable=true)
|
|
*/
|
|
private $desactivationDate;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity=SocialIssue::class, inversedBy="socialActions")
|
|
*/
|
|
private $issue;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity=SocialAction::class, inversedBy="children")
|
|
*/
|
|
private $parent;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity=SocialAction::class, mappedBy="parent")
|
|
*/
|
|
private $children;
|
|
|
|
/**
|
|
* @ORM\Column(type="dateinterval")
|
|
*/
|
|
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")
|
|
*/
|
|
private $results;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->children = new ArrayCollection();
|
|
$this->goals = new ArrayCollection();
|
|
$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)) {
|
|
$this->children[] = $child;
|
|
$child->setParent($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
/**
|
|
* @return Collection|self[] All the descendants (children, children of children, ...)
|
|
*/
|
|
public function getDescendants(): Collection
|
|
{
|
|
$descendants = new ArrayCollection();
|
|
|
|
foreach ($this->getChildren() as $child) {
|
|
if(! $descendants->contains($child)) {
|
|
$descendants->add($child);
|
|
foreach($child->getDescendants() as $descendantsOfChild) {
|
|
if(! $descendants->contains($descendantsOfChild)) {
|
|
$descendants->add($descendantsOfChild);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return $descendants;
|
|
}
|
|
|
|
/**
|
|
* @return Collection|self[] All the descendants with the current entity (this)
|
|
*/
|
|
public function getDescendantsWithThis(): Collection
|
|
{
|
|
$descendants = $this->getDescendants();
|
|
|
|
if(! $descendants->contains($this)) {
|
|
$descendants->add($this);
|
|
}
|
|
|
|
return $descendants;
|
|
}
|
|
|
|
public function getDefaultNotificationDelay(): ?\DateInterval
|
|
{
|
|
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 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|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;
|
|
}
|
|
}
|