mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
Descendants for socialActions & Issues
This commit is contained in:
parent
330234981c
commit
bb71b9f908
@ -111,7 +111,7 @@ class ActivityType extends AbstractType
|
|||||||
return $this->translatableStringHelper->localize($socialIssue->getTitle());
|
return $this->translatableStringHelper->localize($socialIssue->getTitle());
|
||||||
},
|
},
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'choices' => $accompanyingPeriod->getSocialIssues(),
|
'choices' => $accompanyingPeriod->getRecursiveSocialIssues(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ class ActivityType extends AbstractType
|
|||||||
return $this->translatableStringHelper->localize($socialAction->getTitle());
|
return $this->translatableStringHelper->localize($socialAction->getTitle());
|
||||||
},
|
},
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'choices' => $accompanyingPeriod->getSocialActions(),
|
'choices' => $accompanyingPeriod->getRecursiveSocialActions(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -824,20 +824,41 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of all the social actions of the accompanyingPeriod
|
* @return Collection|SocialIssues[] All social issues and their descendants
|
||||||
* i.e. social actions From social issues from the accompanyingPeriod
|
|
||||||
*/
|
*/
|
||||||
public function getSocialActions(): Collection
|
public function getRecursiveSocialIssues(): Collection
|
||||||
{
|
{
|
||||||
$ret = new ArrayCollection();
|
$recursiveSocialIssues = new ArrayCollection();
|
||||||
|
|
||||||
$this->socialIssues->forAll(function($key, $socialIssue) use ($ret) {
|
foreach( $this->socialIssues as $socialIssue) {
|
||||||
$socialIssue->getSocialActions()->forAll(function($key, $socialAction) use ($ret) {
|
foreach ($socialIssue->getDescendantsWithThis() as $descendant) {
|
||||||
$ret->add($socialAction);
|
if(! $recursiveSocialIssues->contains($descendant)) {
|
||||||
});
|
$recursiveSocialIssues->add($descendant);
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $ret;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,6 +139,41 @@ class SocialAction
|
|||||||
return $this;
|
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
|
public function getDefaultNotificationDelay(): ?\DateInterval
|
||||||
{
|
{
|
||||||
return $this->defaultNotificationDelay;
|
return $this->defaultNotificationDelay;
|
||||||
|
@ -107,6 +107,42 @@ class SocialIssue
|
|||||||
return $this;
|
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
|
public function getDesactivationDate(): ?\DateTimeInterface
|
||||||
{
|
{
|
||||||
return $this->desactivationDate;
|
return $this->desactivationDate;
|
||||||
@ -160,4 +196,41 @@ class SocialIssue
|
|||||||
|
|
||||||
return $this;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user