Merge remote-tracking branch 'origin/master' into 103-document-page

This commit is contained in:
2023-06-27 18:31:14 +02:00
51 changed files with 1208 additions and 225 deletions

View File

@@ -185,7 +185,9 @@ class AccompanyingPeriod implements
* cascade={"persist", "remove"},
* orphanRemoval=true
* )
* @ORM\OrderBy({"createdAt": "DESC", "id": "DESC"})
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_DRAFT})
* @var Collection<Comment>
*/
private Collection $comments;
@@ -706,10 +708,11 @@ class AccompanyingPeriod implements
->comments
->filter(
static fn (Comment $c): bool => $c !== $pinnedComment
);
)
;
}
public function getCreatedAt(): ?DateTime
public function getCreatedAt(): DateTimeInterface
{
return $this->createdAt;
}

View File

@@ -59,6 +59,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
* )
* @Serializer\Groups({"read", "docgen:read"})
* @ORM\OrderBy({"startDate": "DESC", "id": "DESC"})
* @var Collection<AccompanyingPeriodWorkEvaluation>
*
* @internal /!\ the serialization for write evaluations is handled in `AccompanyingPeriodWorkDenormalizer`
*/
@@ -278,6 +279,9 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
return $this->accompanyingPeriod;
}
/**
* @return Collection<AccompanyingPeriodWorkEvaluation>
*/
public function getAccompanyingPeriodWorkEvaluations(): Collection
{
return $this->accompanyingPeriodWorkEvaluations;

View File

@@ -79,6 +79,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
* )
* @ORM\OrderBy({"createdAt": "DESC", "id": "DESC"})
* @Serializer\Groups({"read"})
* @var Collection<AccompanyingPeriodWorkEvaluationDocument>
*/
private Collection $documents;
@@ -204,7 +205,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
}
/**
* @return Collection
* @return Collection<AccompanyingPeriodWorkEvaluationDocument>
*/
public function getDocuments()
{

View File

@@ -45,7 +45,7 @@ class PersonCenterCurrent
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="centerCurrent")
* @ORM\OneToOne(targetEntity=Person::class, inversedBy="centerCurrent")
*/
private Person $person;

View File

@@ -15,6 +15,7 @@ use DateInterval;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ReadableCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
@@ -295,6 +296,19 @@ class SocialAction
return 0 < $this->getChildren()->count();
}
public function isDesactivated(\DateTime $atDate): bool
{
if (null !== $this->desactivationDate && $this->desactivationDate < $atDate) {
return true;
}
if ($this->hasParent()) {
return $this->parent->isDesactivated($atDate);
}
return false;
}
public function hasParent(): bool
{
return $this->getParent() instanceof self;
@@ -401,4 +415,14 @@ class SocialAction
return $this;
}
public static function filterRemoveDeactivatedActions(ReadableCollection|array $actions, \DateTime $comparisonDate): ReadableCollection|array
{
$filterFn = fn (SocialAction $socialAction) => !$socialAction->isDesactivated($comparisonDate);
return match ($actions instanceof ReadableCollection) {
true => $actions->filter($filterFn),
false => array_filter($actions, $filterFn)
};
}
}

View File

@@ -253,7 +253,7 @@ class SocialIssue
}
/**
* @return Collection|SocialAction[] All the descendant social actions of all
* @return Collection<SocialAction> All the descendant social actions of all
* the descendants of the entity
*/
public function getRecursiveSocialActions(): Collection
@@ -272,7 +272,7 @@ class SocialIssue
}
/**
* @return Collection|SocialAction[]
* @return Collection<SocialAction>
*/
public function getSocialActions(): Collection
{