mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Merge remote-tracking branch 'origin/master' into features/household-members-list
This commit is contained in:
@@ -53,36 +53,36 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
/**
|
||||
* Mark an accompanying period as "occasional"
|
||||
*
|
||||
*
|
||||
* used in INTENSITY
|
||||
*/
|
||||
public const INTENSITY_OCCASIONAL = 'occasional';
|
||||
|
||||
|
||||
/**
|
||||
* Mark an accompanying period as "regular"
|
||||
*
|
||||
*
|
||||
* used in INTENSITY
|
||||
*/
|
||||
public const INTENSITY_REGULAR = 'regular';
|
||||
|
||||
|
||||
public const INTENSITIES = [self::INTENSITY_OCCASIONAL, self::INTENSITY_REGULAR];
|
||||
|
||||
|
||||
/**
|
||||
* Mark an accompanying period as "draft".
|
||||
*
|
||||
* This means that the accompanying period is not yet
|
||||
*
|
||||
* This means that the accompanying period is not yet
|
||||
* confirmed by the creator
|
||||
*/
|
||||
public const STEP_DRAFT = 'DRAFT';
|
||||
|
||||
|
||||
/**
|
||||
* Mark an accompanying period as "confirmed".
|
||||
*
|
||||
* This means that the accompanying period **is**
|
||||
*
|
||||
* This means that the accompanying period **is**
|
||||
* confirmed by the creator
|
||||
*/
|
||||
public const STEP_CONFIRMED = 'CONFIRMED';
|
||||
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
@@ -176,7 +176,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private $step = self::STEP_DRAFT;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Origin::class)
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
@@ -274,7 +274,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
* )
|
||||
*/
|
||||
private User $updatedBy;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true, options={"default": NULL})
|
||||
*/
|
||||
@@ -412,7 +412,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
if (NULL !== $this->initialComment) {
|
||||
$this->removeComment($this->initialComment);
|
||||
}
|
||||
}
|
||||
if ($comment instanceof Comment) {
|
||||
$this->addComment($comment);
|
||||
}
|
||||
@@ -471,7 +471,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the accompanying period contains a person.
|
||||
* Return true if the accompanying period contains a person.
|
||||
*
|
||||
* **Note**: this participation can be opened or not.
|
||||
*/
|
||||
@@ -518,7 +518,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
return $participation;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Remove Person
|
||||
@@ -822,6 +822,44 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
$this->socialIssues->removeElement($socialIssue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|SocialIssues[] All social issues and their descendants
|
||||
*/
|
||||
public function getRecursiveSocialIssues(): Collection
|
||||
{
|
||||
$recursiveSocialIssues = new ArrayCollection();
|
||||
|
||||
foreach( $this->socialIssues as $socialIssue) {
|
||||
foreach ($socialIssue->getDescendantsWithThis() as $descendant) {
|
||||
if(! $recursiveSocialIssues->contains($descendant)) {
|
||||
$recursiveSocialIssues->add($descendant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $recursiveSocialIssues;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Collection|SocialAction[] All the descendant social actions of all
|
||||
* the descendants of the entity
|
||||
*/
|
||||
public function getRecursiveSocialActions(): Collection
|
||||
{
|
||||
$recursiveSocialActions = new ArrayCollection();
|
||||
|
||||
foreach( $this->socialIssues as $socialIssue) {
|
||||
foreach ($socialIssue->getRecursiveSocialActions() as $descendant) {
|
||||
if(! $recursiveSocialActions->contains($descendant)) {
|
||||
$recursiveSocialActions->add($descendant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $recursiveSocialActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all persons which are participating to this course
|
||||
*
|
||||
|
@@ -102,6 +102,11 @@ class SocialAction
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
public function hasParent(): bool
|
||||
{
|
||||
return $this->getParent() instanceof self;
|
||||
}
|
||||
|
||||
public function setParent(?self $parent): self
|
||||
{
|
||||
$this->parent = $parent;
|
||||
@@ -139,6 +144,41 @@ class SocialAction
|
||||
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;
|
||||
|
@@ -107,6 +107,42 @@ class SocialIssue
|
||||
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 getDesactivationDate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->desactivationDate;
|
||||
@@ -160,4 +196,41 @@ class SocialIssue
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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|SocialAction[] All the descendant social actions of all
|
||||
* the descendants of the entity
|
||||
*/
|
||||
public function getRecursiveSocialActions(): Collection
|
||||
{
|
||||
$recursiveSocialActions = new ArrayCollection();
|
||||
|
||||
foreach ($this->getDescendantsWithThis() as $socialIssue) {
|
||||
foreach ($socialIssue->getDescendantsSocialActions() as $descendant) {
|
||||
if(! $recursiveSocialActions->contains($descendant)) {
|
||||
$recursiveSocialActions->add($descendant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $recursiveSocialActions;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user