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

View File

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

View File

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

View File

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

View File

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