Merge remote-tracking branch 'origin/master' into issue557_address_civility_in_form_person

This commit is contained in:
2022-05-06 10:21:13 +02:00
403 changed files with 2662 additions and 41292 deletions

View File

@@ -361,6 +361,8 @@ class AccompanyingPeriod implements
*/
private Collection $userHistories;
private bool $userIsChanged = false;
/**
* Temporary field, which is filled when the user is changed.
*
@@ -551,8 +553,6 @@ class AccompanyingPeriod implements
* 'now'.
*
* @param mixed $person
*
* @return void
*/
public function closeParticipationFor($person): ?AccompanyingPeriodParticipation
{
@@ -978,6 +978,11 @@ class AccompanyingPeriod implements
return null !== $this->userPrevious;
}
public function isChangedUser(): bool
{
return $this->userIsChanged && $this->user !== $this->userPrevious;
}
/**
* Returns true if the closing date is after the opening date.
*/
@@ -1103,6 +1108,14 @@ class AccompanyingPeriod implements
$this->setStep(AccompanyingPeriod::STEP_CONFIRMED);
}
public function resetPreviousUser(): self
{
$this->userPrevious = null;
$this->userIsChanged = false;
return $this;
}
/**
* @Groups({"write"})
*/
@@ -1243,10 +1256,6 @@ class AccompanyingPeriod implements
*/
public function setPinnedComment(?Comment $comment = null): self
{
if (null !== $this->pinnedComment) {
$this->removeComment($this->pinnedComment);
}
if (null !== $this->pinnedComment) {
$this->addComment($this->pinnedComment);
}
@@ -1329,6 +1338,7 @@ class AccompanyingPeriod implements
{
if ($this->user !== $user) {
$this->userPrevious = $this->user;
$this->userIsChanged = true;
foreach ($this->userHistories as $history) {
if (null === $history->getEndDate()) {

View File

@@ -57,6 +57,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
* orphanRemoval=true
* )
* @Serializer\Groups({"read", "docgen:read"})
* @ORM\OrderBy({"startDate": "DESC", "id": "DESC"})
*
* @internal /!\ the serialization for write evaluations is handled in `AccompanyingPeriodWorkDenormalizer`
*/

View File

@@ -77,6 +77,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
* cascade={"remove", "persist"},
* orphanRemoval=true
* )
* @ORM\OrderBy({"createdAt": "DESC", "id": "DESC"})
* @Serializer\Groups({"read"})
*/
private Collection $documents;

View File

@@ -13,13 +13,12 @@ namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Entity\User;
use DateTimeInterface;
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
use Doctrine\ORM\Mapping as ORM;
use RuntimeException;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
@@ -30,6 +29,10 @@ use Symfony\Component\Serializer\Annotation as Serializer;
*/
class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doctrine\Model\TrackCreationInterface, \Chill\MainBundle\Doctrine\Model\TrackUpdateInterface
{
use TrackCreationTrait;
use TrackUpdateTrait;
/**
* @ORM\ManyToOne(
* targetEntity=AccompanyingPeriodWorkEvaluation::class,
@@ -38,22 +41,6 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
*/
private ?AccompanyingPeriodWorkEvaluation $accompanyingPeriodWorkEvaluation = null;
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
* @Serializer\Groups({"read"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
private ?\DateTimeImmutable $createdAt = null;
/**
* @ORM\ManyToOne(
* targetEntity=User::class
* )
* @Serializer\Groups({"read"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
private ?User $createdBy = null;
/**
* @ORM\Id
* @ORM\GeneratedValue
@@ -88,6 +75,7 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
* @Serializer\Groups({"read"})
* @Serializer\Groups({"write"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
* @Assert\Valid
*/
private ?StoredObject $storedObject = null;
@@ -108,40 +96,11 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
*/
private ?string $title = '';
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
* @Serializer\Groups({"read"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
private ?\DateTimeImmutable $updatedAt = null;
/**
* @ORM\ManyToOne(
* targetEntity=User::class
* )
* @Serializer\Groups({"read"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
private ?User $updatedBy = null;
public function getAccompanyingPeriodWorkEvaluation(): ?AccompanyingPeriodWorkEvaluation
{
return $this->accompanyingPeriodWorkEvaluation;
}
/**
* @return \DateTimeImmutable|null
*/
public function getCreatedAt(): ?DateTimeInterface
{
return $this->createdAt;
}
public function getCreatedBy(): ?User
{
return $this->createdBy;
}
public function getId(): ?int
{
return $this->id;
@@ -170,19 +129,6 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
return $this->title;
}
/**
* @return DateTimeImmutable|null
*/
public function getUpdatedAt(): ?DateTimeInterface
{
return $this->updatedAt;
}
public function getUpdatedBy(): ?User
{
return $this->updatedBy;
}
public function setAccompanyingPeriodWorkEvaluation(?AccompanyingPeriodWorkEvaluation $accompanyingPeriodWorkEvaluation): AccompanyingPeriodWorkEvaluationDocument
{
// if an evaluation is already associated, we cannot change the association (removing the association,
@@ -200,20 +146,6 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
return $this;
}
public function setCreatedAt(DateTimeInterface $datetime): TrackCreationInterface
{
$this->createdAt = $datetime;
return $this;
}
public function setCreatedBy(User $user): TrackCreationInterface
{
$this->createdBy = $user;
return $this;
}
/**
* @param mixed $key
*
@@ -246,18 +178,4 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
return $this;
}
public function setUpdatedAt(DateTimeInterface $datetime): TrackUpdateInterface
{
$this->updatedAt = $datetime;
return $this;
}
public function setUpdatedBy(User $user): TrackUpdateInterface
{
$this->updatedBy = $user;
return $this;
}
}

View File

@@ -19,6 +19,7 @@ use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
@@ -40,6 +41,8 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\Column(type="text")
* @Groups({"read", "write"})
* @Assert\NotBlank
* @Assert\NotNull
*/
private $content;

View File

@@ -240,6 +240,11 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
*/
private array $currentHouseholdAt = [];
/**
* Cache for the computation of current household participation.
*/
private array $currentHouseholdParticipationAt = [];
/**
* The current person address.
*
@@ -875,7 +880,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
}
/**
* @return Collection|BudgetCharges[]
* @return Collection|Charge[]
*/
public function getBudgetCharges(): Collection
{
@@ -883,7 +888,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
}
/**
* @return Collection|BudgetResources[]
* @return Collection|\Chill\BudgetBundle\Entity\Resource[]
*/
public function getBudgetResources(): Collection
{

View File

@@ -15,6 +15,7 @@ use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Validator\Constraints\Relationship\RelationshipNoDuplicate;
use DateTimeImmutable;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
@@ -31,6 +32,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* @DiscriminatorMap(typeProperty="type", mapping={
* "relationship": Relationship::class
* })
* @RelationshipNoDuplicate
*/
class Relationship implements TrackCreationInterface, TrackUpdateInterface
{

View File

@@ -128,6 +128,44 @@ class SocialAction
return $this;
}
/**
* In a SocialIssues's collection, find the elements which are an ancestor of
* other elements.
*
* The difference of the given list (thus, the elements which are **not** kept
* in the returned collection) are the most-grand-child elements of the list.
*
* 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|SocialAction[] $socialActions
*
* @return Collection|SocialAction[] a list with the elements of the given list which are parent of other elements in the given list
*/
public static function findAncestorSocialActions(Collection $socialActions): Collection
{
$ancestors = new ArrayCollection();
foreach ($socialActions as $candidateChild) {
if ($ancestors->contains($candidateChild)) {
continue;
}
foreach ($socialActions as $candidateParent) {
if ($ancestors->contains($candidateParent)) {
continue;
}
if ($candidateChild->isDescendantOf($candidateParent)) {
$ancestors->add($candidateParent);
}
}
}
return $ancestors;
}
/**
* @return Collection|self[]
*/
@@ -169,7 +207,7 @@ class SocialAction
}
/**
* @return Collection|self[] All the descendants with the current entity (this)
* @return Collection|self[] All the descendants including the current entity (this)
*/
public function getDescendantsWithThis(): Collection
{
@@ -233,6 +271,23 @@ class SocialAction
return $this->getParent() instanceof self;
}
/**
* Recursive method which return true if the current $action
* is a descendant of the $action given in parameter.
*/
public function isDescendantOf(SocialAction $action): bool
{
if (!$this->hasParent()) {
return false;
}
if ($this->getParent() === $action) {
return true;
}
return $this->getParent()->isDescendantOf($action);
}
public function removeChild(self $child): self
{
if ($this->children->removeElement($child)) {

View File

@@ -202,7 +202,7 @@ class SocialIssue
}
/**
* @return Collection|self[] All the descendants with the current entity (this)
* @return Collection|self[] All the descendants including the current entity (this)
*/
public function getDescendantsWithThis(): Collection
{