apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -38,38 +38,36 @@ use Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ParticipationOve
use Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ResourceDuplicateCheck;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use DateTime;
use DateTimeImmutable;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\ReadableCollection;
use Doctrine\Common\Collections\Selectable;
use Doctrine\ORM\Mapping as ORM;
use Iterator;
use LogicException;
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Component\Validator\GroupSequenceProviderInterface;
use UnexpectedValueException;
use function array_key_exists;
use const SORT_REGULAR;
/**
* AccompanyingPeriod Class.
*
* @ORM\Entity
*
* @ORM\Table(name="chill_person_accompanying_period")
*
* @DiscriminatorMap(typeProperty="type", mapping={
* "accompanying_period": AccompanyingPeriod::class
* })
*
* @Assert\GroupSequenceProvider
*
* @AccompanyingPeriodValidity(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED})
*
* @LocationValidity(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED})
*
* @ConfidentialCourseMustHaveReferrer(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED})
*/
class AccompanyingPeriod implements
@@ -112,7 +110,7 @@ class AccompanyingPeriod implements
final public const STEP_CONFIRMED = 'CONFIRMED';
/**
* Mark an accompanying period as confirmed, but inactive
* Mark an accompanying period as confirmed, but inactive.
*
* this means that the accompanying period **is**
* confirmed, but no activity (Activity, AccompanyingPeriod, ...)
@@ -121,7 +119,7 @@ class AccompanyingPeriod implements
final public const STEP_CONFIRMED_INACTIVE_SHORT = 'CONFIRMED_INACTIVE_SHORT';
/**
* Mark an accompanying period as confirmed, but inactive
* Mark an accompanying period as confirmed, but inactive.
*
* this means that the accompanying period **is**
* confirmed, but no activity (Activity, AccompanyingPeriod, ...)
@@ -146,36 +144,43 @@ class AccompanyingPeriod implements
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location")
*
* @Groups({"read", "write"})
*
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CONFIRMED})
*/
private ?Location $administrativeLocation = null;
/**
* @var Collection&Selectable<int, Calendar>
*
* @ORM\OneToMany(targetEntity="Chill\CalendarBundle\Entity\Calendar", mappedBy="accompanyingPeriod")
*/
private Collection&Selectable $calendars;
/**
* @ORM\Column(type="date", nullable=true)
*
* @Groups({"read", "write", "docgen:read"})
*
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CLOSED})
*
* @Assert\GreaterThanOrEqual(
* propertyPath="openingDate",
* groups={AccompanyingPeriod::STEP_CLOSED},
* message="The closing date must be later than the date of creation"
* )
*/
private ?DateTime $closingDate = null;
private ?\DateTime $closingDate = null;
/**
* @var AccompanyingPeriod\ClosingMotive
*
* @ORM\ManyToOne(
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive")
*
* @ORM\JoinColumn(nullable=true)
*
* @Groups({"read", "write"})
*
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CLOSED})
*/
private ?ClosingMotive $closingMotive = null;
@@ -186,48 +191,61 @@ 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;
/**
* @ORM\Column(type="boolean", options={"default": false})
*
* @Groups({"read", "write", "docgen:read"})
*/
private bool $confidential = false;
/**
* @ORM\Column(type="datetime", nullable=true, options={"default": NULL})
*
* @Groups({"docgen:read"})
*/
private ?DateTimeInterface $createdAt = null;
private ?\DateTimeInterface $createdAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*
* @ORM\JoinColumn(nullable=true)
*
* @Groups({"read", "docgen:read"})
*/
private ?User $createdBy = null;
/**
* @ORM\Column(type="boolean", options={"default": false})
*
* @Groups({"read", "write", "docgen:read"})
*/
private bool $emergency = false;
/**
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*
* @Groups({"read", "docgen:read"})
*/
private ?int $id = null;
/**
* @ORM\Column(type="string", nullable=true)
*
* @Groups({"read"})
*
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CONFIRMED})
*/
private string $intensity = self::INTENSITY_OCCASIONAL;
@@ -236,13 +254,16 @@ class AccompanyingPeriod implements
* @ORM\ManyToOne(
* targetEntity=UserJob::class
* )
*
* @Groups({"read", "write"})
*
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CONFIRMED})
*/
private ?UserJob $job = null;
/**
* @var Collection<AccompanyingPeriodLocationHistory>
*
* @ORM\OneToMany(targetEntity=AccompanyingPeriodLocationHistory::class,
* mappedBy="period", cascade={"persist", "remove"}, orphanRemoval=true)
*/
@@ -250,16 +271,22 @@ class AccompanyingPeriod implements
/**
* @ORM\Column(type="date")
*
* @Groups({"read", "write", "docgen:read"})
*
* @Assert\LessThan(value="tomorrow", groups={AccompanyingPeriod::STEP_CONFIRMED})
*
* @Assert\LessThanOrEqual(propertyPath="closingDate", groups={AccompanyingPeriod::STEP_CONFIRMED})
*/
private ?DateTime $openingDate = null;
private ?\DateTime $openingDate = null;
/**
* @ORM\ManyToOne(targetEntity=Origin::class)
*
* @ORM\JoinColumn(nullable=true)
*
* @Groups({"read", "write"})
*
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CONFIRMED})
*/
private ?Origin $origin = null;
@@ -268,8 +295,11 @@ class AccompanyingPeriod implements
* @ORM\OneToMany(targetEntity=AccompanyingPeriodParticipation::class,
* mappedBy="accompanyingPeriod", orphanRemoval=true,
* cascade={"persist", "refresh", "remove", "merge", "detach"})
*
* @Groups({"read", "docgen:read"})
*
* @ParticipationOverlap(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED})
*
* @var Collection<AccompanyingPeriodParticipation>
*/
private Collection $participations;
@@ -287,7 +317,9 @@ class AccompanyingPeriod implements
* targetEntity=Comment::class,
* cascade={"persist"},
* )
*
* @Groups({"read"})
*
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private ?Comment $pinnedComment = null;
@@ -296,79 +328,97 @@ class AccompanyingPeriod implements
/**
* @ORM\Column(type="text")
*
* @Groups({"read", "write"})
*/
private string $remark = '';
/**
* @ORM\Column(type="boolean", options={"default": false})
*
* @Groups({"read", "write", "docgen:read"})
*/
private bool $requestorAnonymous = false;
/**
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="accompanyingPeriodRequested")
*
* @ORM\JoinColumn(nullable=true)
*/
private ?Person $requestorPerson = null;
/**
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
*
* @ORM\JoinColumn(nullable=true)
*/
private ?ThirdParty $requestorThirdParty = null;
/**
* @var Collection<Resource>
* @var Collection<resource>
*
* @ORM\OneToMany(
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\Resource",
* mappedBy="accompanyingPeriod",
* cascade={"persist", "remove"},
* orphanRemoval=true
* )
*
* @Groups({"read", "docgen:read"})
*
* @ResourceDuplicateCheck(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED, "Default", "default"})
*/
private Collection $resources;
/**
* @var Collection<Scope>
*
* @ORM\ManyToMany(
* targetEntity=Scope::class,
* cascade={}
* )
*
* @ORM\JoinTable(
* name="accompanying_periods_scopes",
* joinColumns={@ORM\JoinColumn(name="accompanying_period_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="scope_id", referencedColumnName="id")}
* )
*
* @Groups({"read", "docgen:read"})
*
* @Assert\Count(min=1, groups={AccompanyingPeriod::STEP_CONFIRMED}, minMessage="A course must be associated to at least one scope")
*/
private Collection $scopes;
/**
* @var Collection<SocialIssue>
*
* @ORM\ManyToMany(
* targetEntity=SocialIssue::class
* )
*
* @ORM\JoinTable(
* name="chill_person_accompanying_period_social_issues"
* )
*
* @Groups({"read", "docgen:read"})
*
* @Assert\Count(min=1, groups={AccompanyingPeriod::STEP_CONFIRMED}, minMessage="A course must contains at least one social issue")
*/
private Collection $socialIssues;
/**
* @ORM\Column(type="string", length=32, nullable=true)
*
* @Groups({"read"})
*
* @var AccompanyingPeriod::STEP_*
*/
private string $step = self::STEP_DRAFT;
/**
* @var Collection<AccompanyingPeriodStepHistory>
*
* @ORM\OneToMany(targetEntity=AccompanyingPeriodStepHistory::class,
* mappedBy="period", cascade={"persist", "remove"}, orphanRemoval=true)
*/
@@ -377,7 +427,7 @@ class AccompanyingPeriod implements
/**
* @ORM\Column(type="datetime", nullable=true, options={"default": NULL})
*/
private ?DateTimeInterface $updatedAt = null;
private ?\DateTimeInterface $updatedAt = null;
/**
* @ORM\ManyToOne(
@@ -388,7 +438,9 @@ class AccompanyingPeriod implements
/**
* @ORM\ManyToOne(targetEntity=User::class)
*
* @ORM\JoinColumn(nullable=true)
*
* @Groups({"read", "write", "docgen:read"})
*/
private ?User $user = null;
@@ -412,10 +464,12 @@ class AccompanyingPeriod implements
/**
* @var Collection<AccompanyingPeriodWork>
*
* @ORM\OneToMany(
* targetEntity=AccompanyingPeriodWork::class,
* mappedBy="accompanyingPeriod"
* )
*
* @Assert\Valid(traverse=true)
*/
private Collection $works;
@@ -423,11 +477,9 @@ class AccompanyingPeriod implements
/**
* AccompanyingPeriod constructor.
*
* @param DateTime $dateOpening
*
* @uses AccompanyingPeriod::setClosingDate()
*/
public function __construct(?DateTime $dateOpening = null)
public function __construct(\DateTime $dateOpening = null)
{
$this->calendars = new ArrayCollection(); // TODO we cannot add a dependency between AccompanyingPeriod and calendars
$this->participations = new ArrayCollection();
@@ -439,7 +491,7 @@ class AccompanyingPeriod implements
$this->userHistories = new ArrayCollection();
$this->locationHistories = new ArrayCollection();
$this->stepHistories = new ArrayCollection();
$this->setOpeningDate($dateOpening ?? new DateTime('now'));
$this->setOpeningDate($dateOpening ?? new \DateTime('now'));
}
/**
@@ -462,7 +514,7 @@ class AccompanyingPeriod implements
foreach ($participations as $p) {
$households[] = $p->getPerson()->getCurrentHousehold();
}
$households = array_unique($households, SORT_REGULAR);
$households = array_unique($households, \SORT_REGULAR);
$array = [];
@@ -492,7 +544,7 @@ class AccompanyingPeriod implements
public function addLocationHistory(AccompanyingPeriodLocationHistory $history): self
{
if ($this->getStep() === self::STEP_DRAFT) {
if (self::STEP_DRAFT === $this->getStep()) {
return $this;
}
@@ -505,7 +557,7 @@ class AccompanyingPeriod implements
$criteria = new Criteria();
$criteria->orderBy(['startDate' => Criteria::ASC, 'id' => Criteria::ASC]);
/** @var Iterator $locations */
/** @var \Iterator $locations */
$locations = $this->getLocationHistories()->matching($criteria)->getIterator();
$locations->rewind();
@@ -523,7 +575,7 @@ class AccompanyingPeriod implements
return $this;
}
public function addPerson(?Person $person = null): self
public function addPerson(Person $person = null): self
{
if (null !== $person) {
$this->createParticipationFor($person);
@@ -574,7 +626,7 @@ class AccompanyingPeriod implements
*/
public function canBeReOpened(Person $person): bool
{
if ($this->isOpen() === true) {
if (true === $this->isOpen()) {
return false;
}
@@ -600,7 +652,7 @@ class AccompanyingPeriod implements
$participation = $this->getOpenParticipationContainsPerson($person);
if ($participation instanceof AccompanyingPeriodParticipation) {
$participation->setEndDate(new DateTime('now'));
$participation->setEndDate(new \DateTime('now'));
}
return $participation;
@@ -660,7 +712,7 @@ class AccompanyingPeriod implements
public function getCenter(): ?Center
{
if ($this->getPersons()->count() === 0) {
if (0 === $this->getPersons()->count()) {
return null;
}
@@ -674,7 +726,7 @@ class AccompanyingPeriod implements
foreach ($this->getPersons() as $person) {
if (
null !== $person->getCenter()
&& !array_key_exists(spl_object_hash($person->getCenter()), $centers)
&& !\array_key_exists(spl_object_hash($person->getCenter()), $centers)
) {
$centers[spl_object_hash($person->getCenter())] = $person->getCenter();
}
@@ -685,10 +737,8 @@ class AccompanyingPeriod implements
/**
* Get closingDate.
*
* @return DateTime
*/
public function getClosingDate(): ?DateTime
public function getClosingDate(): ?\DateTime
{
return $this->closingDate;
}
@@ -700,6 +750,7 @@ class AccompanyingPeriod implements
/**
* @Groups({"read"})
*
* @return ReadableCollection<(int|string), Comment>
*/
public function getComments(): ReadableCollection
@@ -714,7 +765,7 @@ class AccompanyingPeriod implements
;
}
public function getCreatedAt(): ?DateTimeInterface
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
@@ -734,17 +785,17 @@ class AccompanyingPeriod implements
public function getGroupSequence()
{
if ($this->getStep() === self::STEP_DRAFT) {
if (self::STEP_DRAFT === $this->getStep()) {
return [[self::STEP_DRAFT]];
}
if (str_starts_with($this->getStep(), 'CONFIRM')) {
return [[self::STEP_DRAFT, self::STEP_CONFIRMED]];
}
if ($this->getStep() === self::STEP_CLOSED) {
if (self::STEP_CLOSED === $this->getStep()) {
return [[self::STEP_DRAFT, self::STEP_CONFIRMED, self::STEP_CLOSED]];
}
throw new LogicException('no validation group permitted with this step: ' . $this->getStep());
throw new \LogicException('no validation group permitted with this step: '.$this->getStep());
}
public function getId(): ?int
@@ -778,7 +829,7 @@ class AccompanyingPeriod implements
*
* @Groups({"read"})
*/
public function getLocation(?DateTimeImmutable $at = null): ?Address
public function getLocation(\DateTimeImmutable $at = null): ?Address
{
if ($this->getPersonLocation() instanceof Person) {
return $this->getPersonLocation()->getCurrentPersonAddress();
@@ -799,6 +850,7 @@ class AccompanyingPeriod implements
* Get where the location is.
*
* @Groups({"read"})
*
* @return 'person'|'address'|'none'
*/
public function getLocationStatus(): string
@@ -816,10 +868,10 @@ class AccompanyingPeriod implements
public function getNextCalendarsForPerson(Person $person, $limit = 5): ReadableCollection
{
$today = new DateTimeImmutable('today');
$today = new \DateTimeImmutable('today');
$criteria = Criteria::create()
->where(Criteria::expr()->gte('startDate', $today))
//->andWhere(Criteria::expr()->memberOf('persons', $person))
// ->andWhere(Criteria::expr()->memberOf('persons', $person))
->orderBy(['startDate' => 'DESC'])
->setMaxResults($limit * 2);
@@ -834,10 +886,8 @@ class AccompanyingPeriod implements
/**
* Get openingDate.
*
* @return DateTime
*/
public function getOpeningDate(): ?DateTime
public function getOpeningDate(): ?\DateTime
{
return $this->openingDate;
}
@@ -877,6 +927,7 @@ class AccompanyingPeriod implements
/**
* Get Participations Collection.
*
* @return Collection<AccompanyingPeriodParticipation>
*/
public function getParticipations(): Collection
@@ -886,6 +937,7 @@ class AccompanyingPeriod implements
/**
* Get the participation containing a person.
*
* @return ReadableCollection<(int|string), AccompanyingPeriodParticipation>
*/
public function getParticipationsContainsPerson(Person $person): ReadableCollection
@@ -934,7 +986,7 @@ class AccompanyingPeriod implements
/**
* @return Collection|SocialAction[] All the descendant social actions of all
* the descendants of the entity
* the descendants of the entity
*/
public function getRecursiveSocialActions(): Collection
{
@@ -1109,11 +1161,11 @@ class AccompanyingPeriod implements
public function isOpen(): bool
{
if ($this->getOpeningDate() > new DateTimeImmutable('now')) {
if ($this->getOpeningDate() > new \DateTimeImmutable('now')) {
return false;
}
if ($this->getClosingDate() === null) {
if (null === $this->getClosingDate()) {
return true;
}
@@ -1205,7 +1257,7 @@ class AccompanyingPeriod implements
/**
* @Groups({"write"})
*/
public function setAddressLocation(?Address $addressLocation = null): self
public function setAddressLocation(Address $addressLocation = null): self
{
if ($this->addressLocation !== $addressLocation) {
$this->addressLocation = $addressLocation;
@@ -1214,7 +1266,7 @@ class AccompanyingPeriod implements
$this->setPersonLocation(null);
$locationHistory = new AccompanyingPeriodLocationHistory();
$locationHistory
->setStartDate(new DateTimeImmutable('now'))
->setStartDate(new \DateTimeImmutable('now'))
->setAddressLocation($addressLocation);
$this->addLocationHistory($locationHistory);
@@ -1236,7 +1288,6 @@ class AccompanyingPeriod implements
*
* For closing a Person file, you should use Person::setClosed instead.
*
*
* @return AccompanyingPeriod
*/
public function setClosingDate(mixed $closingDate)
@@ -1246,7 +1297,7 @@ class AccompanyingPeriod implements
return $this;
}
public function setClosingMotive(?ClosingMotive $closingMotive = null): self
public function setClosingMotive(ClosingMotive $closingMotive = null): self
{
$this->closingMotive = $closingMotive;
@@ -1260,7 +1311,7 @@ class AccompanyingPeriod implements
return $this;
}
public function setCreatedAt(DateTimeInterface $datetime): self
public function setCreatedAt(\DateTimeInterface $datetime): self
{
$this->createdAt = $datetime;
@@ -1298,7 +1349,6 @@ class AccompanyingPeriod implements
/**
* Set openingDate.
*
*
* @return AccompanyingPeriod
*/
public function setOpeningDate(mixed $openingDate)
@@ -1322,7 +1372,7 @@ class AccompanyingPeriod implements
/**
* @Groups({"write"})
*/
public function setPersonLocation(?Person $person = null): self
public function setPersonLocation(Person $person = null): self
{
if ($this->personLocation !== $person) {
$this->personLocation = $person;
@@ -1331,7 +1381,7 @@ class AccompanyingPeriod implements
$this->setAddressLocation(null);
$locationHistory = new AccompanyingPeriodLocationHistory();
$locationHistory
->setStartDate(new DateTimeImmutable('now'))
->setStartDate(new \DateTimeImmutable('now'))
->setPersonLocation($person);
$this->addLocationHistory($locationHistory);
@@ -1344,7 +1394,7 @@ class AccompanyingPeriod implements
/**
* @Groups({"write"})
*/
public function setPinnedComment(?Comment $comment = null): self
public function setPinnedComment(Comment $comment = null): self
{
if (null !== $this->pinnedComment) {
$this->addComment($this->pinnedComment);
@@ -1355,7 +1405,7 @@ class AccompanyingPeriod implements
return $this;
}
public function setRemark(?string $remark = null): self
public function setRemark(string $remark = null): self
{
$this->remark = (string) $remark;
@@ -1369,7 +1419,9 @@ class AccompanyingPeriod implements
* instance of Person
*
* @param $requestor Person|ThirdParty
*
* @throw UnexpectedValueException if the requestor is not a Person or ThirdParty
*
* @Groups({"write"})
*/
public function setRequestor($requestor): self
@@ -1384,7 +1436,7 @@ class AccompanyingPeriod implements
$this->setRequestorPerson(null);
$this->setRequestorThirdParty(null);
} else {
throw new UnexpectedValueException('requestor is not an instance of Person or ThirdParty');
throw new \UnexpectedValueException('requestor is not an instance of Person or ThirdParty');
}
return $this;
@@ -1410,7 +1462,7 @@ class AccompanyingPeriod implements
if (self::STEP_DRAFT !== $this->step && $previous !== $step) {
// we create a new history
$history = new AccompanyingPeriodStepHistory();
$history->setStep($this->step)->setStartDate(new DateTimeImmutable('now'));
$history->setStep($this->step)->setStartDate(new \DateTimeImmutable('now'));
$this->addStepHistory($history);
}
@@ -1418,7 +1470,7 @@ class AccompanyingPeriod implements
return $this;
}
public function setUpdatedAt(DateTimeInterface $datetime): self
public function setUpdatedAt(\DateTimeInterface $datetime): self
{
$this->updatedAt = $datetime;
@@ -1441,7 +1493,7 @@ class AccompanyingPeriod implements
foreach ($this->userHistories as $history) {
if (null === $history->getEndDate()) {
$history->setEndDate(new DateTimeImmutable('now'));
$history->setEndDate(new \DateTimeImmutable('now'));
}
}
@@ -1471,7 +1523,7 @@ class AccompanyingPeriod implements
// first location history
$locationHistory = new AccompanyingPeriodLocationHistory();
$locationHistory
->setStartDate(new DateTimeImmutable('now'))
->setStartDate(new \DateTimeImmutable('now'))
->setPersonLocation($this->getPersonLocation())
->setAddressLocation($this->getAddressLocation());
$this->addLocationHistory($locationHistory);
@@ -1483,7 +1535,7 @@ class AccompanyingPeriod implements
$criteria = new Criteria();
$criteria->orderBy(['startDate' => Criteria::ASC, 'id' => Criteria::ASC]);
/** @var Iterator $steps */
/** @var \Iterator $steps */
$steps = $this->getStepHistories()->matching($criteria)->getIterator();
$steps->rewind();
@@ -1498,7 +1550,7 @@ class AccompanyingPeriod implements
if ($this->getOpeningDate()->format('Y-m-d') !== $current->getStartDate()->format('Y-m-d')
&& ($this->getOpeningDate() <= $current->getEndDate() || null === $current->getEndDate())) {
$current->setStartDate(DateTimeImmutable::createFromMutable($this->getOpeningDate()));
$current->setStartDate(\DateTimeImmutable::createFromMutable($this->getOpeningDate()));
}
// then we set all the end date to the start date of the next one
@@ -1514,14 +1566,14 @@ class AccompanyingPeriod implements
} while ($steps->valid());
}
private function setRequestorPerson(?Person $requestorPerson = null): self
private function setRequestorPerson(Person $requestorPerson = null): self
{
$this->requestorPerson = $requestorPerson;
return $this;
}
private function setRequestorThirdParty(?ThirdParty $requestorThirdParty = null): self
private function setRequestorThirdParty(ThirdParty $requestorThirdParty = null): self
{
$this->requestorThirdParty = $requestorThirdParty;

View File

@@ -16,7 +16,7 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Doctrine\ORM\Mapping as ORM;
/**
* Informations about AccompanyingPeriod
* Informations about AccompanyingPeriod.
*
* This entity allow access to some basic information about the AccompanyingPeriod. It is
* populated from a SQL view, dynamically build from various sources.
@@ -26,6 +26,7 @@ use Doctrine\ORM\Mapping as ORM;
* - get the user involved with an accompanying period
*
* @ORM\Entity()
*
* @ORM\Table(name="view_chill_person_accompanying_period_info")
*/
class AccompanyingPeriodInfo
@@ -33,44 +34,53 @@ class AccompanyingPeriodInfo
public function __construct(
/**
* @var AccompanyingPeriod
*
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class)
*/
public readonly AccompanyingPeriod $accompanyingPeriod,
/**
* @var string
*
* @ORM\Column(type="text")
*
* @ORM\Id
*/
public readonly string $relatedEntity,
/**
* @var int
*
* @ORM\Column(type="integer")
*
* @ORM\Id
*/
public readonly int $relatedEntityId,
/**
* @var User
*
* @ORM\ManyToOne(targetEntity=User::class)
*/
public readonly ?User $user,
public readonly ?User $user,
/**
* @var \DateTimeImmutable
*
* @ORM\Column(type="datetime_immutable")
*/
public readonly \DateTimeImmutable $infoDate,
/**
* @var array
*
* @ORM\Column(type="json")
*/
public readonly array $metadata,
/**
* @var string
*
* @ORM\Column(type="text")
*/
public readonly string $discriminator,

View File

@@ -16,11 +16,11 @@ use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
use Chill\MainBundle\Entity\Address;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*
* @ORM\Table("chill_person_accompanying_period_location_history")
*/
class AccompanyingPeriodLocationHistory implements TrackCreationInterface
@@ -35,11 +35,13 @@ class AccompanyingPeriodLocationHistory implements TrackCreationInterface
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*/
private ?DateTimeImmutable $endDate = null;
private ?\DateTimeImmutable $endDate = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
@@ -57,14 +59,14 @@ class AccompanyingPeriodLocationHistory implements TrackCreationInterface
/**
* @ORM\Column(type="date_immutable")
*/
private ?DateTimeImmutable $startDate = null;
private ?\DateTimeImmutable $startDate = null;
public function getAddressLocation(): ?Address
{
return $this->addressLocation;
}
public function getEndDate(): ?DateTimeImmutable
public function getEndDate(): ?\DateTimeImmutable
{
return $this->endDate;
}
@@ -84,7 +86,7 @@ class AccompanyingPeriodLocationHistory implements TrackCreationInterface
return $this->personLocation;
}
public function getStartDate(): ?DateTimeImmutable
public function getStartDate(): ?\DateTimeImmutable
{
return $this->startDate;
}
@@ -96,7 +98,7 @@ class AccompanyingPeriodLocationHistory implements TrackCreationInterface
return $this;
}
public function setEndDate(?DateTimeImmutable $endDate): AccompanyingPeriodLocationHistory
public function setEndDate(?\DateTimeImmutable $endDate): AccompanyingPeriodLocationHistory
{
$this->endDate = $endDate;
@@ -120,7 +122,7 @@ class AccompanyingPeriodLocationHistory implements TrackCreationInterface
return $this;
}
public function setStartDate(?DateTimeImmutable $startDate): AccompanyingPeriodLocationHistory
public function setStartDate(?\DateTimeImmutable $startDate): AccompanyingPeriodLocationHistory
{
$this->startDate = $startDate;

View File

@@ -17,11 +17,11 @@ use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*
* @ORM\Table("chill_person_accompanying_period_step_history")
*/
class AccompanyingPeriodStepHistory implements TrackCreationInterface, TrackUpdateInterface
@@ -33,11 +33,13 @@ class AccompanyingPeriodStepHistory implements TrackCreationInterface, TrackUpda
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*/
private ?DateTimeImmutable $endDate = null;
private ?\DateTimeImmutable $endDate = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
@@ -50,14 +52,14 @@ class AccompanyingPeriodStepHistory implements TrackCreationInterface, TrackUpda
/**
* @ORM\Column(type="date_immutable")
*/
private ?DateTimeImmutable $startDate = null;
private ?\DateTimeImmutable $startDate = null;
/**
* @ORM\Column(type="text", nullable=false)
*/
private string $step;
public function getEndDate(): ?DateTimeImmutable
public function getEndDate(): ?\DateTimeImmutable
{
return $this->endDate;
}
@@ -72,7 +74,7 @@ class AccompanyingPeriodStepHistory implements TrackCreationInterface, TrackUpda
return $this->period;
}
public function getStartDate(): ?DateTimeImmutable
public function getStartDate(): ?\DateTimeImmutable
{
return $this->startDate;
}
@@ -82,7 +84,7 @@ class AccompanyingPeriodStepHistory implements TrackCreationInterface, TrackUpda
return $this->step;
}
public function setEndDate(?DateTimeImmutable $endDate): self
public function setEndDate(?\DateTimeImmutable $endDate): self
{
$this->endDate = $endDate;
@@ -99,7 +101,7 @@ class AccompanyingPeriodStepHistory implements TrackCreationInterface, TrackUpda
return $this;
}
public function setStartDate(?DateTimeImmutable $startDate): self
public function setStartDate(?\DateTimeImmutable $startDate): self
{
$this->startDate = $startDate;

View File

@@ -22,19 +22,18 @@ use Chill\PersonBundle\Entity\SocialWork\Result;
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use DateTimeImmutable;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ReadableCollection;
use Doctrine\ORM\Mapping as ORM;
use LogicException;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
*
* @ORM\Table(name="chill_person_accompanying_period_work")
*
* @Serializer\DiscriminatorMap(
* typeProperty="type",
* mapping={
@@ -46,7 +45,9 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
{
/**
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class)
*
* @Serializer\Groups({"read", "read:accompanyingPeriodWork:light"})
*
* @Serializer\Context(normalizationContext={"groups": {"read"}}, groups={"read:accompanyingPeriodWork:light"})
*/
private ?AccompanyingPeriod $accompanyingPeriod = null;
@@ -58,8 +59,11 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
* cascade={"remove", "persist"},
* orphanRemoval=true
* )
*
* @Serializer\Groups({"read", "docgen:read"})
*
* @ORM\OrderBy({"startDate": "DESC", "id": "DESC"})
*
* @var Collection<AccompanyingPeriodWorkEvaluation>
*
* @internal /!\ the serialization for write evaluations is handled in `AccompanyingPeriodWorkDenormalizer`
@@ -68,48 +72,57 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
/**
* @ORM\Column(type="datetime_immutable")
*
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
*/
private ?DateTimeImmutable $createdAt = null;
private ?\DateTimeImmutable $createdAt = null;
/**
* @ORM\Column(type="boolean")
*
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
*/
private bool $createdAutomatically = false;
/**
* @ORM\Column(type="text")
*
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
*/
private string $createdAutomaticallyReason = '';
/**
* @ORM\ManyToOne(targetEntity=User::class)
*
* @ORM\JoinColumn(nullable=false)
*
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
*/
private ?User $createdBy = null;
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*
* @Serializer\Groups({"accompanying_period_work:create"})
* @Serializer\Groups({"accompanying_period_work:edit"})
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
*
* @Assert\GreaterThanOrEqual(propertyPath="startDate",
* message="accompanying_course_work.The endDate should be greater or equal than the start date"
* )
*/
private ?DateTimeImmutable $endDate = null;
private ?\DateTimeImmutable $endDate = null;
/**
* @var Collection<AccompanyingPeriodWorkGoal>
*
* @ORM\OneToMany(
* targetEntity=AccompanyingPeriodWorkGoal::class,
* mappedBy="accompanyingPeriodWork",
* cascade={"persist"},
* orphanRemoval=true
* )
*
* @Serializer\Groups({"read", "docgen:read"})
* @Serializer\Groups({"accompanying_period_work:edit"})
*/
@@ -117,6 +130,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
/**
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
*
* @Serializer\Groups({"read", "docgen:read"})
* @Serializer\Groups({"accompanying_period_work:edit"})
*
@@ -126,22 +140,29 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light", "read:evaluation:include-work"})
*/
private ?int $id = null;
/**
* @ORM\Column(type="text")
*
* @Serializer\Groups({"read", "accompanying_period_work:edit", "docgen:read"})
*/
private string $note = '';
/**
* @var Collection<Person>
*
* @ORM\ManyToMany(targetEntity=Person::class)
*
* @ORM\JoinTable(name="chill_person_accompanying_period_work_person")
*
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
* @Serializer\Groups({"accompanying_period_work:edit"})
* @Serializer\Groups({"accompanying_period_work:create"})
@@ -150,20 +171,25 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
/**
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable", columnPrefix="privateComment_")
*
* @Serializer\Groups({"read", "accompanying_period_work:edit"})
*/
private PrivateCommentEmbeddable $privateComment;
/**
* @var Collection<int, AccompanyingPeriodWorkReferrerHistory>
*
* @ORM\OneToMany(targetEntity=AccompanyingPeriodWorkReferrerHistory::class, cascade={"persist", "remove"}, mappedBy="accompanyingPeriodWork", orphanRemoval=true)
*/
private Collection $referrersHistory;
/**
* @var Collection<Result>
*
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorks")
*
* @ORM\JoinTable(name="chill_person_accompanying_period_work_result")
*
* @Serializer\Groups({"read", "docgen:read"})
* @Serializer\Groups({"accompanying_period_work:edit"})
*/
@@ -171,26 +197,32 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
/**
* @ORM\ManyToOne(targetEntity=SocialAction::class)
*
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
* @Serializer\Groups({"accompanying_period_work:create"})
*
* @Serializer\Context(normalizationContext={"groups": {"read"}}, groups={"read:accompanyingPeriodWork:light"})
*/
private ?SocialAction $socialAction = null;
/**
* @ORM\Column(type="date_immutable")
*
* @Serializer\Groups({"accompanying_period_work:create"})
* @Serializer\Groups({"accompanying_period_work:edit"})
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
*/
private ?DateTimeImmutable $startDate = null;
private ?\DateTimeImmutable $startDate = null;
/**
* @var Collection<ThirdParty>
*
* @ORM\ManyToMany(targetEntity=ThirdParty::class)
*
* @ORM\JoinTable(name="chill_person_accompanying_period_work_third_party")
*
* In schema : intervenants
*
* @Serializer\Groups({"read", "docgen:read"})
* @Serializer\Groups({"accompanying_period_work:edit"})
*/
@@ -198,13 +230,16 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
/**
* @ORM\Column(type="datetime_immutable")
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?DateTimeImmutable $updatedAt = null;
private ?\DateTimeImmutable $updatedAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*
* @ORM\JoinColumn(nullable=false)
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?User $updatedBy = null;
@@ -253,7 +288,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
{
if (!$this->getReferrers()->contains($referrer)) {
$this->referrersHistory[] =
new AccompanyingPeriodWorkReferrerHistory($this, $referrer, new DateTimeImmutable('today'));
new AccompanyingPeriodWorkReferrerHistory($this, $referrer, new \DateTimeImmutable('today'));
}
return $this;
@@ -290,7 +325,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
return $this->accompanyingPeriodWorkEvaluations;
}
public function getCreatedAt(): ?DateTimeImmutable
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
@@ -310,7 +345,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
return $this->createdBy;
}
public function getEndDate(): ?DateTimeInterface
public function getEndDate(): ?\DateTimeInterface
{
return $this->endDate;
}
@@ -350,6 +385,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
/**
* @return ReadableCollection<int, User>
*
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
* @Serializer\Groups({"accompanying_period_work:edit"})
* @Serializer\Groups({"accompanying_period_work:create"})
@@ -366,7 +402,6 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
return $this->referrersHistory;
}
/**
* @return Collection<int, Result>
*/
@@ -385,7 +420,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
return new ArrayCollection([$this->getSocialAction()->getIssue()]);
}
public function getStartDate(): ?DateTimeInterface
public function getStartDate(): ?\DateTimeInterface
{
return $this->startDate;
}
@@ -403,7 +438,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
return $this->getThirdParties();
}
public function getUpdatedAt(): ?DateTimeImmutable
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
@@ -445,7 +480,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
{
foreach ($this->referrersHistory as $history) {
if ($history->isOpen() && $referrer === $history->getUser()) {
$history->setEndDate(new DateTimeImmutable('today'));
$history->setEndDate(new \DateTimeImmutable('today'));
if ($history->isDateRangeEmpty()) {
$history->removeAccompanyingPeriodWork();
@@ -488,7 +523,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
$this->accompanyingPeriod instanceof AccompanyingPeriod
&& $accompanyingPeriod !== $this->accompanyingPeriod
) {
throw new LogicException('A work cannot change accompanyingPeriod');
throw new \LogicException('A work cannot change accompanyingPeriod');
}
$this->accompanyingPeriod = $accompanyingPeriod;
@@ -496,7 +531,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
return $this;
}
public function setCreatedAt(DateTimeInterface $createdAt): self
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
@@ -524,7 +559,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
return $this;
}
public function setEndDate(?DateTimeInterface $endDate = null): self
public function setEndDate(\DateTimeInterface $endDate = null): self
{
$this->endDate = $endDate;
@@ -559,14 +594,14 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
return $this;
}
public function setStartDate(DateTimeInterface $startDate): self
public function setStartDate(\DateTimeInterface $startDate): self
{
$this->startDate = $startDate;
return $this;
}
public function setUpdatedAt(DateTimeInterface $datetime): TrackUpdateInterface
public function setUpdatedAt(\DateTimeInterface $datetime): TrackUpdateInterface
{
$this->updatedAt = $datetime;

View File

@@ -16,18 +16,16 @@ use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
use DateInterval;
use DateTimeImmutable;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use LogicException;
use RuntimeException;
use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Entity
*
* @ORM\Table("chill_person_accompanying_period_work_evaluation")
*
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
* "accompanying_period_work_evaluation": AccompanyingPeriodWorkEvaluation::class,
* })
@@ -39,13 +37,16 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
* targetEntity=AccompanyingPeriodWork::class,
* inversedBy="accompanyingPeriodWorkEvaluations"
* )
*
* @Serializer\Groups({"read:evaluation:include-work"})
*
* @Serializer\Context(normalizationContext={"groups": {"read:accompanyingPeriodWork:light"}}, groups={"read:evaluation:include-work"})
*/
private ?AccompanyingPeriodWork $accompanyingPeriodWork = null;
/**
* @ORM\Column(type="text", nullable=false, options={"default": ""})
*
* @Serializer\Groups({"read", "docgen:read"})
* @Serializer\Groups({"write"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
@@ -54,14 +55,16 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?DateTimeImmutable $createdAt = null;
private ?\DateTimeImmutable $createdAt = null;
/**
* @ORM\ManyToOne(
* targetEntity=User::class
* )
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?User $createdBy = null;
@@ -77,24 +80,29 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
* cascade={"remove", "persist"},
* orphanRemoval=true
* )
*
* @ORM\OrderBy({"createdAt": "DESC", "id": "DESC"})
*
* @Serializer\Groups({"read"})
*
* @var Collection<AccompanyingPeriodWorkEvaluationDocument>
*/
private Collection $documents;
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*
* @Serializer\Groups({"read", "docgen:read"})
* @Serializer\Groups({"write"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
private ?DateTimeImmutable $endDate = null;
private ?\DateTimeImmutable $endDate = null;
/**
* @ORM\ManyToOne(
* targetEntity=Evaluation::class
* )
*
* @Serializer\Groups({"read", "docgen:read"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
@@ -102,8 +110,11 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?int $id = null;
@@ -118,51 +129,55 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
* @Serializer\Groups({"read"})
* @Serializer\Groups({"write"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*
* @var mixed
*/
private $key;
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*
* @Serializer\Groups({"read", "docgen:read"})
* @Serializer\Groups({"write"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
private ?DateTimeImmutable $maxDate = null;
private ?\DateTimeImmutable $maxDate = null;
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*
* @Serializer\Groups({"read", "docgen:read"})
* @Serializer\Groups({"write"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
private ?DateTimeImmutable $startDate = null;
private ?\DateTimeImmutable $startDate = null;
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?DateTimeImmutable $updatedAt = null;
private ?\DateTimeImmutable $updatedAt = null;
/**
* @ORM\ManyToOne(
* targetEntity=User::class
* )
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?User $updatedBy = null;
/**
* @ORM\Column(type="dateinterval", nullable=true, options={"default": null})
*
* @Serializer\Groups({"read"})
* @Serializer\Groups({"write"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
private ?DateInterval $warningInterval = null;
private ?\DateInterval $warningInterval = null;
/**
* @ORM\Column(type="integer", nullable=true)
*
* @Serializer\Groups({"read", "docgen:read"})
* @Serializer\Groups({"write"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
@@ -194,7 +209,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
return $this->comment;
}
public function getCreatedAt(): ?DateTimeImmutable
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
@@ -212,7 +227,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
return $this->documents;
}
public function getEndDate(): ?DateTimeImmutable
public function getEndDate(): ?\DateTimeImmutable
{
return $this->endDate;
}
@@ -229,25 +244,23 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
/**
* Arbitrary data, used for client.
*
* @return mixed
*/
public function getKey()
{
return $this->key;
}
public function getMaxDate(): ?DateTimeImmutable
public function getMaxDate(): ?\DateTimeImmutable
{
return $this->maxDate;
}
public function getStartDate(): ?DateTimeImmutable
public function getStartDate(): ?\DateTimeImmutable
{
return $this->startDate;
}
public function getUpdatedAt(): ?DateTimeImmutable
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
@@ -260,7 +273,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
/**
* @Serializer\Groups({"docgen:read"})
*/
public function getWarningDate(): ?DateTimeImmutable
public function getWarningDate(): ?\DateTimeImmutable
{
if (null === $this->getEndDate() || null === $this->getWarningInterval()) {
return null;
@@ -269,7 +282,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
return $this->getEndDate()->sub($this->getWarningInterval());
}
public function getWarningInterval(): ?DateInterval
public function getWarningInterval(): ?\DateInterval
{
return $this->warningInterval;
}
@@ -294,8 +307,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
&& $this->accompanyingPeriodWork instanceof AccompanyingPeriodWork
&& $this->accompanyingPeriodWork->getId() !== $accompanyingPeriodWork->getId()
) {
throw new RuntimeException('Changing the ' .
'accompanyingPeriodWork is not allowed');
throw new \RuntimeException('Changing the accompanyingPeriodWork is not allowed');
}
$this->accompanyingPeriodWork = $accompanyingPeriodWork;
@@ -311,11 +323,9 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
}
/**
* @param DateTimeImmutable|null $createdAt
*
* @return AccompanyingPeriodWorkEvaluation
* @param \DateTimeImmutable|null $createdAt
*/
public function setCreatedAt(DateTimeInterface $createdAt): self
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
@@ -329,7 +339,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
return $this;
}
public function setEndDate(?DateTimeImmutable $endDate): AccompanyingPeriodWorkEvaluation
public function setEndDate(?\DateTimeImmutable $endDate): AccompanyingPeriodWorkEvaluation
{
$this->endDate = $endDate;
@@ -354,7 +364,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
) {
$cl = AccompanyingPeriodWorkEvaluation::class;
throw new LogicException("once set, an {$cl} cannot
throw new \LogicException("once set, an {$cl} cannot
change or remove the linked Evaluation::class");
}
@@ -365,8 +375,6 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
/**
* Arbitrary data, used for client.
*
*
*/
public function setKey(mixed $key): self
{
@@ -375,14 +383,14 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
return $this;
}
public function setMaxDate(?DateTimeImmutable $maxDate): AccompanyingPeriodWorkEvaluation
public function setMaxDate(?\DateTimeImmutable $maxDate): AccompanyingPeriodWorkEvaluation
{
$this->maxDate = $maxDate;
return $this;
}
public function setStartDate(?DateTimeImmutable $startDate): AccompanyingPeriodWorkEvaluation
public function setStartDate(?\DateTimeImmutable $startDate): AccompanyingPeriodWorkEvaluation
{
$this->startDate = $startDate;
@@ -390,11 +398,9 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
}
/**
* @param DateTimeImmutable|null $updatedAt
*
* @return AccompanyingPeriodWorkEvaluation
* @param \DateTimeImmutable|null $updatedAt
*/
public function setUpdatedAt(DateTimeInterface $updatedAt): self
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
@@ -408,7 +414,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
return $this;
}
public function setWarningInterval(?DateInterval $warningInterval): AccompanyingPeriodWorkEvaluation
public function setWarningInterval(?\DateInterval $warningInterval): AccompanyingPeriodWorkEvaluation
{
$this->warningInterval = $warningInterval;

View File

@@ -16,13 +16,14 @@ use Chill\DocStoreBundle\Entity\StoredObject;
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
*
* @ORM\Table("chill_person_accompanying_period_work_evaluation_document")
*
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
* "accompanying_period_work_evaluation_document": AccompanyingPeriodWorkEvaluationDocument::class
* })
@@ -43,11 +44,15 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @internal the default name exceeds 64 characters, we must set manually:
*
* @ORM\SequenceGenerator(sequenceName="chill_person_social_work_eval_doc_id_seq", allocationSize=1, initialValue=1000)
*
* @Serializer\Groups({"read"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
@@ -63,8 +68,6 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
* @Serializer\Groups({"read"})
* @Serializer\Groups({"write"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*
* @var mixed
*/
private $key;
@@ -72,9 +75,11 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
* @ORM\ManyToOne(
* targetEntity=StoredObject::class,
* )
*
* @Serializer\Groups({"read"})
* @Serializer\Groups({"write"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*
* @Assert\Valid
*/
private ?StoredObject $storedObject = null;
@@ -83,6 +88,7 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
* @ORM\ManyToOne(
* targetEntity=DocGeneratorTemplate::class
* )
*
* @Serializer\Groups({"read"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
@@ -90,6 +96,7 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
/**
* @ORM\Column(type="text", nullable=false, options={"default": ""})
*
* @Serializer\Groups({"read"})
* @Serializer\Groups({"write"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
@@ -106,9 +113,6 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
return $this->id;
}
/**
* @return mixed
*/
public function getKey()
{
return $this->key;
@@ -138,7 +142,7 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
&& $accompanyingPeriodWorkEvaluation instanceof AccompanyingPeriodWorkEvaluation
) {
if ($this->accompanyingPeriodWorkEvaluation !== $accompanyingPeriodWorkEvaluation) {
throw new RuntimeException('It is not allowed to change the evaluation for a document');
throw new \RuntimeException('It is not allowed to change the evaluation for a document');
}
}
$this->accompanyingPeriodWorkEvaluation = $accompanyingPeriodWorkEvaluation;

View File

@@ -16,12 +16,13 @@ use Chill\PersonBundle\Entity\SocialWork\Result;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use LogicException;
use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Entity
*
* @ORM\Table(name="chill_person_accompanying_period_work_goal")
*
* @Serializer\DiscriminatorMap(
* typeProperty="type",
* mapping={
@@ -38,6 +39,7 @@ class AccompanyingPeriodWorkGoal
/**
* @ORM\ManyToOne(targetEntity=Goal::class)
*
* @Serializer\Groups({"accompanying_period_work:edit"})
* @Serializer\Groups({"read", "docgen:read"})
*/
@@ -45,14 +47,18 @@ class AccompanyingPeriodWorkGoal
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?int $id = null;
/**
* @ORM\Column(type="text")
*
* @Serializer\Groups({"accompanying_period_work:edit"})
* @Serializer\Groups({"read"})
*/
@@ -60,8 +66,11 @@ class AccompanyingPeriodWorkGoal
/**
* @var Collection<Result>
*
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorkGoals")
*
* @ORM\JoinTable(name="chill_person_accompanying_period_work_goal_result")
*
* @Serializer\Groups({"accompanying_period_work:edit"})
* @Serializer\Groups({"read", "docgen:read"})
*/
@@ -123,7 +132,7 @@ class AccompanyingPeriodWorkGoal
&& $accompanyingPeriodWork !== $this->accompanyingPeriodWork
&& null !== $accompanyingPeriodWork
) {
throw new LogicException('Change accompanying period work is not allowed');
throw new \LogicException('Change accompanying period work is not allowed');
}
$this->accompanyingPeriodWork = $accompanyingPeriodWork;

View File

@@ -20,6 +20,7 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*
* @ORM\Table(name="chill_person_accompanying_period_work_referrer")
*/
class AccompanyingPeriodWorkReferrerHistory implements TrackCreationInterface, TrackUpdateInterface
@@ -29,13 +30,14 @@ class AccompanyingPeriodWorkReferrerHistory implements TrackCreationInterface, T
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @var \DateTimeImmutable|null
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*/
private ?\DateTimeImmutable $endDate = null;
@@ -47,11 +49,13 @@ class AccompanyingPeriodWorkReferrerHistory implements TrackCreationInterface, T
private ?AccompanyingPeriodWork $accompanyingPeriodWork,
/**
* @var User
*
* @ORM\ManyToOne(targetEntity=User::class)
*/
private User $user,
/**
* @var \DateTimeImmutable
*
* @ORM\Column(type="date_immutable", nullable=false)
*/
private \DateTimeImmutable $startDate
@@ -70,6 +74,7 @@ class AccompanyingPeriodWorkReferrerHistory implements TrackCreationInterface, T
public function setEndDate(?\DateTimeImmutable $endDate): AccompanyingPeriodWorkReferrerHistory
{
$this->endDate = $endDate;
return $this;
}
@@ -89,9 +94,7 @@ class AccompanyingPeriodWorkReferrerHistory implements TrackCreationInterface, T
}
/**
* to be used when the history is removed (when startDate = endDate)
*
* @return self
* to be used when the history is removed (when startDate = endDate).
*/
public function removeAccompanyingPeriodWork(): self
{
@@ -111,7 +114,7 @@ class AccompanyingPeriodWorkReferrerHistory implements TrackCreationInterface, T
/**
* return true if the date range is empty (start date and end date are equal).
*
* @return bool true if the start date and end date are equal.
* @return bool true if the start date and end date are equal
*/
public function isDateRangeEmpty(): bool
{

View File

@@ -20,6 +20,7 @@ use Symfony\Component\Serializer\Annotation as Serializer;
* ClosingMotive give an explanation why we closed the Accompanying period.
*
* @ORM\Entity
*
* @ORM\Table(name="chill_person_accompanying_period_closingmotive")
*/
class ClosingMotive
@@ -33,6 +34,7 @@ class ClosingMotive
* Child Accompanying periods.
*
* @var Collection<ClosingMotive>
*
* @ORM\OneToMany(
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive",
* mappedBy="parent")
@@ -40,18 +42,21 @@ class ClosingMotive
private Collection $children;
/**
* @var int
*
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*
* @Serializer\Groups({"docgen:read"})
*/
private ?int $id = null;
/**
* @ORM\Column(type="json")
*
* @Serializer\Groups({"docgen:read"})
*
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
*/
private array $name = [];
@@ -62,8 +67,6 @@ class ClosingMotive
private float $ordering = 0.0;
/**
* @var self
*
* @ORM\ManyToOne(
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive",
* inversedBy="children")
@@ -155,7 +158,7 @@ class ClosingMotive
public function isLeaf(): bool
{
return $this->children->count() === 0;
return 0 === $this->children->count();
}
public function isParent(): bool
@@ -229,7 +232,7 @@ class ClosingMotive
$this->parent = $parent;
if (null !== $parent) {
//$parent->addChildren($this);
// $parent->addChildren($this);
}
return $this;

View File

@@ -15,7 +15,6 @@ use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
use Symfony\Component\Serializer\Annotation\Groups;
@@ -23,7 +22,9 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
*
* @ORM\Table(name="chill_person_accompanying_period_comment")
*
* @DiscriminatorMap(typeProperty="type", mapping={
* "accompanying_period_comment": Comment::class
* })
@@ -34,48 +35,61 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface
* @ORM\ManyToOne(
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod",
* inversedBy="comments")
*
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
*/
private ?AccompanyingPeriod $accompanyingPeriod = null;
/**
* @ORM\Column(type="text")
*
* @Groups({"read", "write", "docgen:read"})
*
* @Assert\NotBlank
*
* @Assert\NotNull
*/
private ?string $content = null;
/**
* @ORM\Column(type="datetime")
*
* @Groups({"read", "docgen:read"})
*/
private ?DateTimeInterface $createdAt = null;
private ?\DateTimeInterface $createdAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*
* @ORM\JoinColumn(nullable=false)
*
* @Groups({"read", "docgen:read"})
*/
private ?User $creator = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Groups({"read", "docgen:read"})
*/
private ?int $id = null;
/**
* @ORM\Column(type="datetime")
*
* @Groups({"read"})
*/
private ?DateTimeInterface $updatedAt = null;
private ?\DateTimeInterface $updatedAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*
* @ORM\JoinColumn(nullable=false)
*
* @Groups({"read"})
*/
private ?User $updatedBy = null;
@@ -90,7 +104,7 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface
return $this->content;
}
public function getCreatedAt(): ?DateTimeInterface
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
@@ -105,7 +119,7 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface
return $this->id;
}
public function getUpdatedAt(): ?DateTimeInterface
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
@@ -134,7 +148,7 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface
return $this;
}
public function setCreatedAt(DateTimeInterface $createdAt): self
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
@@ -153,7 +167,7 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface
return $this;
}
public function setUpdatedAt(DateTimeInterface $updatedAt): self
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;

View File

@@ -11,13 +11,14 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Entity
*
* @ORM\Table(name="chill_person_accompanying_period_origin")
*
* @Serializer\DiscriminatorMap(
* typeProperty="type",
* mapping={
@@ -28,24 +29,30 @@ class Origin
{
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?int $id = null;
/**
* @ORM\Column(type="json")
*
* @Serializer\Groups({"read", "docgen:read"})
*
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
*/
private array $label = [];
/**
* @ORM\Column(type="date_immutable", nullable=true)
*
* @Serializer\Groups({"read"})
*/
private ?DateTimeImmutable $noActiveAfter = null;
private ?\DateTimeImmutable $noActiveAfter = null;
public function getId(): ?int
{
@@ -57,7 +64,7 @@ class Origin
return $this->label;
}
public function getNoActiveAfter(): ?DateTimeImmutable
public function getNoActiveAfter(): ?\DateTimeImmutable
{
return $this->noActiveAfter;
}
@@ -69,7 +76,7 @@ class Origin
return $this;
}
public function setNoActiveAfter(?DateTimeImmutable $noActiveAfter): self
public function setNoActiveAfter(?\DateTimeImmutable $noActiveAfter): self
{
$this->noActiveAfter = $noActiveAfter;

View File

@@ -17,19 +17,21 @@ use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
use Symfony\Component\Serializer\Annotation\Groups;
use UnexpectedValueException;
/**
* **About denormalization**: this operation is operated by @see{AccompanyingPeriodResourdeNormalizer}.
*
* @ORM\Entity
*
* @ORM\Table(
* name="chill_person_accompanying_period_resource",
* uniqueConstraints={
*
* @ORM\UniqueConstraint(name="person_unique", columns={"person_id", "accompanyingperiod_id"}),
* @ORM\UniqueConstraint(name="thirdparty_unique", columns={"thirdparty_id", "accompanyingperiod_id"})
* }
* )
*
* @DiscriminatorMap(typeProperty="type", mapping={
* "accompanying_period_resource": Resource::class
* })
@@ -41,34 +43,43 @@ class Resource
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod",
* inversedBy="resources"
* )
*
* @ORM\JoinColumn(nullable=false)
*/
private ?AccompanyingPeriod $accompanyingPeriod = null;
/**
* @ORM\Column(type="text", nullable=true)
*
* @Groups({"read", "docgen:read"})
*/
private ?string $comment = '';
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Groups({"read", "docgen:read"})
*/
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity=Person::class)
*
* @ORM\JoinColumn(nullable=true)
*
* @Groups({"docgen:read"})
*/
private ?Person $person = null;
/**
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
*
* @ORM\JoinColumn(nullable=true)
*
* @Groups({"docgen:read"})
*/
private ?ThirdParty $thirdParty = null;
@@ -113,7 +124,7 @@ class Resource
return $this;
}
public function setComment(?string $comment = null): self
public function setComment(string $comment = null): self
{
$this->comment = (string) $comment;
@@ -135,12 +146,7 @@ class Resource
$this->setPerson(null);
$this->setThirdParty(null);
} else {
throw new UnexpectedValueException(sprintf(
'the resource ' .
'should be an instance of %s or %s',
Person::class,
ThirdParty::class
));
throw new \UnexpectedValueException(sprintf('the resource should be an instance of %s or %s', Person::class, ThirdParty::class));
}
return $this;

View File

@@ -15,11 +15,11 @@ use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*
* @ORM\Table("chill_person_accompanying_period_user_history")
*/
class UserHistory implements TrackCreationInterface
@@ -29,11 +29,13 @@ class UserHistory implements TrackCreationInterface
/**
* @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null})
*/
private ?DateTimeImmutable $endDate = null;
private ?\DateTimeImmutable $endDate = null;
/**
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
@@ -41,11 +43,13 @@ class UserHistory implements TrackCreationInterface
public function __construct(
/**
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="userHistories")
*
* @ORM\JoinColumn(nullable=false)
*/
private ?\Chill\PersonBundle\Entity\AccompanyingPeriod $accompanyingPeriod,
private ?AccompanyingPeriod $accompanyingPeriod,
/**
* @ORM\ManyToOne(targetEntity=User::class)
*
* @ORM\JoinColumn(nullable=false)
*/
private User $user,
@@ -53,7 +57,7 @@ class UserHistory implements TrackCreationInterface
/**
* @ORM\Column(type="datetime_immutable", nullable=false, options={"default": "now()"})
*/
private DateTimeImmutable $startDate = new DateTimeImmutable('now')
private \DateTimeImmutable $startDate = new \DateTimeImmutable('now')
) {}
public function getAccompanyingPeriod(): AccompanyingPeriod
@@ -61,7 +65,7 @@ class UserHistory implements TrackCreationInterface
return $this->accompanyingPeriod;
}
public function getEndDate(): ?DateTimeImmutable
public function getEndDate(): ?\DateTimeImmutable
{
return $this->endDate;
}
@@ -71,7 +75,7 @@ class UserHistory implements TrackCreationInterface
return $this->id;
}
public function getStartDate(): DateTimeImmutable
public function getStartDate(): \DateTimeImmutable
{
return $this->startDate;
}
@@ -81,7 +85,7 @@ class UserHistory implements TrackCreationInterface
return $this->user;
}
public function setEndDate(?DateTimeImmutable $endDate): UserHistory
public function setEndDate(?\DateTimeImmutable $endDate): UserHistory
{
$this->endDate = $endDate;

View File

@@ -11,8 +11,6 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Entity;
use DateTime;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
use Symfony\Component\Serializer\Annotation\Groups;
@@ -21,7 +19,9 @@ use Symfony\Component\Serializer\Annotation\Groups;
* AccompanyingPeriodParticipation Class.
*
* @ORM\Entity
*
* @ORM\Table(name="chill_person_accompanying_period_participation")
*
* @DiscriminatorMap(typeProperty="type", mapping={
* "accompanying_period_participation": AccompanyingPeriodParticipation::class
* })
@@ -30,36 +30,44 @@ class AccompanyingPeriodParticipation
{
/**
* @ORM\Column(type="date", nullable=true)
*
* @Groups({"read", "docgen:read"})
*/
private ?DateTime $endDate = null;
private ?\DateTime $endDate = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Groups({"read", "docgen:read"})
*/
private ?int $id = null;
/**
* @ORM\Column(type="date", nullable=false)
*
* @Groups({"read", "docgen:read"})
*/
private ?DateTime $startDate = null;
private ?\DateTime $startDate = null;
public function __construct(/**
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="participations", cascade={"persist"})
*
* @ORM\JoinColumn(name="accompanyingperiod_id", referencedColumnName="id", nullable=false)
*/
private ?\Chill\PersonBundle\Entity\AccompanyingPeriod $accompanyingPeriod, /**
private ?AccompanyingPeriod $accompanyingPeriod, /**
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="accompanyingPeriodParticipations")
*
* @ORM\JoinColumn(name="person_id", referencedColumnName="id", nullable=false)
*
* @Groups({"read", "docgen:read"})
*/
private ?\Chill\PersonBundle\Entity\Person $person
private ?Person $person
) {
$this->startDate = new DateTime('now');
$this->startDate = new \DateTime('now');
$person->getAccompanyingPeriodParticipations()->add($this);
}
@@ -68,7 +76,7 @@ class AccompanyingPeriodParticipation
return $this->accompanyingPeriod;
}
public function getEndDate(): ?DateTimeInterface
public function getEndDate(): ?\DateTimeInterface
{
return $this->endDate;
}
@@ -83,7 +91,7 @@ class AccompanyingPeriodParticipation
return $this->person;
}
public function getStartDate(): ?DateTimeInterface
public function getStartDate(): ?\DateTimeInterface
{
return $this->startDate;
}
@@ -100,7 +108,7 @@ class AccompanyingPeriodParticipation
return $this;
}
public function setEndDate(?DateTime $endDate): self
public function setEndDate(?\DateTime $endDate): self
{
$this->endDate = $endDate;

View File

@@ -18,5 +18,5 @@ interface HasPerson
{
public function getPerson(): ?Person;
public function setPerson(?Person $person = null): HasPerson;
public function setPerson(Person $person = null): HasPerson;
}

View File

@@ -11,14 +11,10 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Entity\Household;
use ArrayIterator;
use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Validator\Constraints\Household\MaxHolder;
use DateTime;
use DateTimeImmutable;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
@@ -27,18 +23,19 @@ use Doctrine\Common\Collections\Selectable;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function count;
/**
* @ORM\Entity
*
* @ORM\Table(
* name="chill_person_household"
* )
*
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
* "household": Household::class
* })
*
* @MaxHolder(groups={"household_memberships"})
*/
class Household
@@ -47,11 +44,15 @@ class Household
* Addresses.
*
* @var Collection<Address>
*
* @ORM\ManyToMany(
* targetEntity="Chill\MainBundle\Entity\Address",
* cascade={"persist", "remove", "merge", "detach"})
*
* @ORM\JoinTable(name="chill_person_household_to_addresses")
*
* @ORM\OrderBy({"validFrom": "DESC", "id": "DESC"})
*
* @Serializer\Groups({"write"})
*/
private Collection $addresses;
@@ -63,46 +64,56 @@ class Household
/**
* @var Collection&Selectable<int, HouseholdComposition>
*
* @ORM\OneToMany(
* targetEntity=HouseholdComposition::class,
* mappedBy="household",
* orphanRemoval=true,
* cascade={"persist"}
* )
*
* @ORM\OrderBy({"startDate": "DESC"})
*
* @Assert\Valid(traverse=true, groups={"household_composition"})
*/
private Collection&Selectable $compositions;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?int $id = null;
/**
* @var Collection<HouseholdMember>
*
* @ORM\OneToMany(
* targetEntity=HouseholdMember::class,
* mappedBy="household"
* )
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private Collection $members;
/**
* @ORM\Column(type="boolean", name="waiting_for_birth", options={"default": false})
*
* @Serializer\Groups({"docgen:read"})
*/
private bool $waitingForBirth = false;
/**
* @ORM\Column(type="date_immutable", name="waiting_for_birth_date", nullable=true, options={"default": null})
*
* @Serializer\Groups({"docgen:read"})
*/
private ?DateTimeImmutable $waitingForBirthDate = null;
private ?\DateTimeImmutable $waitingForBirthDate = null;
public function __construct()
{
@@ -200,11 +211,12 @@ class Household
/**
* @Serializer\Groups({"read", "docgen:read"})
*
* @Serializer\SerializedName("current_address")
*/
public function getCurrentAddress(?DateTime $at = null): ?Address
public function getCurrentAddress(\DateTime $at = null): ?Address
{
$at ??= new DateTime('today');
$at ??= new \DateTime('today');
$addrs = $this->getAddresses()->filter(static fn (Address $a) => $a->getValidFrom() <= $at && (
null === $a->getValidTo() || $a->getValidTo() > $at
@@ -219,11 +231,12 @@ class Household
/**
* @Serializer\Groups({"docgen:read"})
*
* @Serializer\SerializedName("current_composition")
*/
public function getCurrentComposition(?DateTimeImmutable $at = null): ?HouseholdComposition
public function getCurrentComposition(\DateTimeImmutable $at = null): ?HouseholdComposition
{
$at ??= new DateTimeImmutable('today');
$at ??= new \DateTimeImmutable('today');
$criteria = new Criteria();
$expr = Criteria::expr();
@@ -249,12 +262,12 @@ class Household
/**
* @Serializer\Groups({"docgen:read"})
*/
public function getCurrentMembers(?DateTimeImmutable $now = null): Collection
public function getCurrentMembers(\DateTimeImmutable $now = null): Collection
{
return $this->getMembers()->matching($this->buildCriteriaCurrentMembers($now));
}
public function getCurrentMembersByPosition(Position $position, ?DateTimeInterface $now = null)
public function getCurrentMembersByPosition(Position $position, \DateTimeInterface $now = null)
{
$criteria = new Criteria();
$expr = Criteria::expr();
@@ -270,9 +283,10 @@ class Household
* Used in serialization
*
* @Serializer\Groups({"read"})
*
* @Serializer\SerializedName("current_members_id")
*/
public function getCurrentMembersIds(?DateTimeImmutable $now = null): ReadableCollection
public function getCurrentMembersIds(\DateTimeImmutable $now = null): ReadableCollection
{
return $this->getCurrentMembers($now)->map(
static fn (HouseholdMember $m) => $m->getId()
@@ -282,22 +296,22 @@ class Household
/**
* @return HouseholdMember[]
*/
public function getCurrentMembersOrdered(?DateTimeImmutable $now = null): Collection
public function getCurrentMembersOrdered(\DateTimeImmutable $now = null): Collection
{
$members = $this->getCurrentMembers($now);
$members->getIterator()
->uasort(
static function (HouseholdMember $a, HouseholdMember $b) {
if ($a->getPosition() === null) {
if ($b->getPosition() === null) {
if (null === $a->getPosition()) {
if (null === $b->getPosition()) {
return 0;
}
return -1;
}
if ($b->getPosition() === null) {
if (null === $b->getPosition()) {
return 1;
}
@@ -324,7 +338,7 @@ class Household
return $members;
}
public function getCurrentMembersWithoutPosition(?DateTimeInterface $now = null)
public function getCurrentMembersWithoutPosition(\DateTimeInterface $now = null)
{
$criteria = new Criteria();
$expr = Criteria::expr();
@@ -341,7 +355,7 @@ class Household
*
* @return ReadableCollection<(int|string), Person>
*/
public function getCurrentPersons(?DateTimeImmutable $now = null): ReadableCollection
public function getCurrentPersons(\DateTimeImmutable $now = null): ReadableCollection
{
return $this->getCurrentMembers($now)
->map(static fn (HouseholdMember $m) => $m->getPerson());
@@ -387,7 +401,7 @@ class Household
return $this->getMembers()->matching($criteria);
}
public function getMembersOnRange(DateTimeImmutable $from, ?DateTimeImmutable $to): ReadableCollection
public function getMembersOnRange(\DateTimeImmutable $from, ?\DateTimeImmutable $to): ReadableCollection
{
return $this->getMembers()->filter(static function (HouseholdMember $m) use ($from, $to) {
if (null === $m->getEndDate() && null !== $to) {
@@ -410,11 +424,11 @@ class Household
});
}
public function getNonCurrentMembers(?DateTimeImmutable $now = null): Collection
public function getNonCurrentMembers(\DateTimeImmutable $now = null): Collection
{
$criteria = new Criteria();
$expr = Criteria::expr();
$date = $now ?? new DateTimeImmutable('today');
$date = $now ?? new \DateTimeImmutable('today');
$criteria
->where(
@@ -430,7 +444,7 @@ class Household
return $this->getMembers()->matching($criteria);
}
public function getNonCurrentMembersByPosition(Position $position, ?DateTimeInterface $now = null)
public function getNonCurrentMembersByPosition(Position $position, \DateTimeInterface $now = null)
{
$criteria = new Criteria();
$expr = Criteria::expr();
@@ -440,7 +454,7 @@ class Household
return $this->getNonCurrentMembers($now)->matching($criteria);
}
public function getNonCurrentMembersWithoutPosition(?DateTimeInterface $now = null)
public function getNonCurrentMembersWithoutPosition(\DateTimeInterface $now = null)
{
$criteria = new Criteria();
$expr = Criteria::expr();
@@ -474,7 +488,7 @@ class Household
public function getPreviousAddressOf(Address $address): ?Address
{
$iterator = new ArrayIterator($this->getAddressesOrdered());
$iterator = new \ArrayIterator($this->getAddressesOrdered());
$iterator->rewind();
while ($iterator->valid()) {
@@ -496,7 +510,7 @@ class Household
return $this->waitingForBirth;
}
public function getWaitingForBirthDate(): ?DateTimeImmutable
public function getWaitingForBirthDate(): ?\DateTimeImmutable
{
return $this->waitingForBirthDate;
}
@@ -513,7 +527,7 @@ class Household
static fn (HouseholdComposition $a, HouseholdComposition $b) => $a->getStartDate() <=> $b->getStartDate()
);
$iterator = new ArrayIterator($compositionOrdered);
$iterator = new \ArrayIterator($compositionOrdered);
$iterator->rewind();
/** @var ?HouseholdComposition $previous */
@@ -535,7 +549,7 @@ class Household
public function makeAddressConsistent(): void
{
$iterator = new ArrayIterator($this->getAddressesOrdered());
$iterator = new \ArrayIterator($this->getAddressesOrdered());
$iterator->rewind();
@@ -597,7 +611,7 @@ class Household
*/
public function setForceAddress(Address $address)
{
$address->setValidFrom(new DateTime('today'));
$address->setValidFrom(new \DateTime('today'));
$this->addAddress($address);
}
@@ -608,7 +622,7 @@ class Household
return $this;
}
public function setWaitingForBirthDate(?DateTimeImmutable $waitingForBirthDate): self
public function setWaitingForBirthDate(?\DateTimeImmutable $waitingForBirthDate): self
{
$this->waitingForBirthDate = $waitingForBirthDate;
@@ -620,7 +634,7 @@ class Household
$addresses = $this->getAddresses();
$cond = true;
for ($i = 0; count($addresses) - 1 > $i; ++$i) {
for ($i = 0; \count($addresses) - 1 > $i; ++$i) {
if ($addresses[$i]->getValidFrom() !== $addresses[$i + 1]->getValidTo()) {
$cond = false;
$context->buildViolation('The address are not sequentials. The validFrom date of one address should be equal to the validTo date of the previous address.')
@@ -630,11 +644,11 @@ class Household
}
}
private function buildCriteriaCurrentMembers(?DateTimeImmutable $now = null): Criteria
private function buildCriteriaCurrentMembers(\DateTimeImmutable $now = null): Criteria
{
$criteria = new Criteria();
$expr = Criteria::expr();
$date = $now ?? new DateTimeImmutable('today');
$date = $now ?? new \DateTimeImmutable('today');
$criteria
->where($expr->orX(

View File

@@ -16,16 +16,17 @@ use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
*
* @ORM\Table(
* name="chill_person_household_composition"
* )
*
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
* "household_composition_type": HouseholdCompositionType::class
* })
@@ -43,46 +44,59 @@ class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterfa
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*
* @Assert\GreaterThanOrEqual(propertyPath="startDate", groups={"Default", "household_composition"})
*
* @Serializer\Groups({"docgen:read"})
*/
private ?DateTimeImmutable $endDate = null;
private ?\DateTimeImmutable $endDate = null;
/**
* @ORM\ManyToOne(targetEntity=Household::class, inversedBy="compositions")
*
* @ORM\JoinColumn(nullable=false)
*/
private ?Household $household = null;
/**
* @ORM\ManyToOne(targetEntity=HouseholdCompositionType::class)
*
* @ORM\JoinColumn(nullable=false)
*
* @Serializer\Groups({"docgen:read"})
*/
private ?HouseholdCompositionType $householdCompositionType = null;
private ?HouseholdCompositionType $householdCompositionType = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?int $id = null;
/**
* @ORM\Column(type="integer", nullable=true, options={"default": null})
*
* @Assert\NotNull
*
* @Assert\GreaterThanOrEqual(0, groups={"Default", "household_composition"})
*
* @Serializer\Groups({"docgen:read"})
*/
private ?int $numberOfChildren = null;
/**
* @ORM\Column(type="date_immutable", nullable=false)
*
* @Assert\NotNull(groups={"Default", "household_composition"})
*
* @Serializer\Groups({"docgen:read"})
*/
private ?DateTimeImmutable $startDate = null;
private ?\DateTimeImmutable $startDate = null;
public function __construct()
{
@@ -94,7 +108,7 @@ class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterfa
return $this->comment;
}
public function getEndDate(): ?DateTimeImmutable
public function getEndDate(): ?\DateTimeImmutable
{
return $this->endDate;
}
@@ -119,7 +133,7 @@ class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterfa
return $this->numberOfChildren;
}
public function getStartDate(): ?DateTimeImmutable
public function getStartDate(): ?\DateTimeImmutable
{
return $this->startDate;
}
@@ -131,7 +145,7 @@ class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterfa
return $this;
}
public function setEndDate(?DateTimeImmutable $endDate): HouseholdComposition
public function setEndDate(?\DateTimeImmutable $endDate): HouseholdComposition
{
$this->endDate = $endDate;
@@ -163,7 +177,7 @@ class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterfa
return $this;
}
public function setStartDate(?DateTimeImmutable $startDate): HouseholdComposition
public function setStartDate(?\DateTimeImmutable $startDate): HouseholdComposition
{
$this->startDate = $startDate;

View File

@@ -16,9 +16,11 @@ use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Entity
*
* @ORM\Table(
* name="chill_person_household_composition_type"
* )
*
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
* "household_composition_type": HouseholdCompositionType::class
* })
@@ -32,15 +34,20 @@ class HouseholdCompositionType
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?int $id = null;
/**
* @ORM\Column(type="json")
*
* @Serializer\Groups({"read", "docgen:read"})
*
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
*/
private array $label = [];

View File

@@ -12,14 +12,13 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Entity\Household;
use Chill\PersonBundle\Entity\Person;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
use LogicException;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
*
* @ORM\Table(
* name="chill_person_household_members"
* )
@@ -28,59 +27,71 @@ class HouseholdMember
{
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?string $comment = null;
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*
* @Serializer\Groups({"read", "docgen:read"})
*
* @Assert\GreaterThanOrEqual(
* propertyPath="startDate",
* message="household_membership.The end date must be after start date",
* groups={"household_memberships"}
* )
*/
private ?DateTimeImmutable $endDate = null;
private ?\DateTimeImmutable $endDate = null;
/**
* @ORM\Column(type="boolean", options={"default": false})
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private bool $holder = false;
/**
* @var Household
* @ORM\ManyToOne(
* targetEntity="\Chill\PersonBundle\Entity\Household\Household"
* )
*
* @Assert\Valid(groups={"household_memberships"})
*
* @Assert\NotNull(groups={"household_memberships"})
*/
private ?Household $household = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?int $id = null;
/**
* @var Person
* @ORM\ManyToOne(
* targetEntity="\Chill\PersonBundle\Entity\Person"
* )
*
* @Serializer\Groups({"read", "docgen:read"})
*
* @Serializer\Context({"docgen:person:with-household": false})
*
* @Assert\Valid(groups={"household_memberships"})
*
* @Assert\NotNull(groups={"household_memberships"})
*/
private ?Person $person = null;
/**
* @ORM\ManyToOne(targetEntity=Position::class)
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?Position $position = null;
@@ -92,17 +103,19 @@ class HouseholdMember
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*
* @Serializer\Groups({"read", "docgen:read"})
*
* @Assert\NotNull(groups={"household_memberships"})
*/
private ?DateTimeImmutable $startDate = null;
private ?\DateTimeImmutable $startDate = null;
public function getComment(): ?string
{
return $this->comment;
}
public function getEndDate(): ?DateTimeImmutable
public function getEndDate(): ?\DateTimeImmutable
{
return $this->endDate;
}
@@ -135,14 +148,14 @@ class HouseholdMember
return $this->shareHousehold;
}
public function getStartDate(): ?DateTimeImmutable
public function getStartDate(): ?\DateTimeImmutable
{
return $this->startDate;
}
public function isCurrent(?DateTimeImmutable $at = null): bool
public function isCurrent(\DateTimeImmutable $at = null): bool
{
$at ??= new DateTimeImmutable('now');
$at ??= new \DateTimeImmutable('now');
return $this->getStartDate() < $at && (
null === $this->getEndDate() || $this->getEndDate() > $at
@@ -161,7 +174,7 @@ class HouseholdMember
return $this;
}
public function setEndDate(?DateTimeImmutable $endDate = null): self
public function setEndDate(\DateTimeImmutable $endDate = null): self
{
$this->endDate = $endDate;
@@ -178,8 +191,7 @@ class HouseholdMember
public function setHousehold(?Household $household): self
{
if ($this->household instanceof Household) {
throw new LogicException('You cannot change household ' .
'on a membership');
throw new \LogicException('You cannot change household on a membership');
}
$this->household = $household;
@@ -190,8 +202,7 @@ class HouseholdMember
public function setPerson(?Person $person): self
{
if ($this->person instanceof Person) {
throw new LogicException('You cannot change person ' .
'on a membership');
throw new \LogicException('You cannot change person on a membership');
}
$this->person = $person;
@@ -203,8 +214,7 @@ class HouseholdMember
public function setPosition(?Position $position): self
{
if ($this->position instanceof Position && $this->position !== $position) {
throw new LogicException('The position is already set. You cannot change ' .
'a position of a membership');
throw new \LogicException('The position is already set. You cannot change a position of a membership');
}
$this->position = $position;
@@ -223,7 +233,7 @@ class HouseholdMember
return $this;
}
public function setStartDate(DateTimeImmutable $startDate): self
public function setStartDate(\DateTimeImmutable $startDate): self
{
$this->startDate = $startDate;

View File

@@ -13,8 +13,6 @@ namespace Chill\PersonBundle\Entity\Household;
use Chill\MainBundle\Entity\Address;
use Chill\PersonBundle\Entity\Person;
use DateTimeImmutable;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
/**
@@ -42,27 +40,34 @@ use Doctrine\ORM\Mapping as ORM;
* 3. 3st entity: from 2021-12-01 to NULL, household V, address T;
*
* @ORM\Entity(readOnly=true)
*
* @ORM\Table(name="view_chill_person_household_address")
*/
class PersonHouseholdAddress
{
/**
* @ORM\Id
*
* @ORM\ManyToOne(targetEntity=Address::class)
*
* @ORM\JoinColumn(nullable=false)
*/
private ?\Chill\MainBundle\Entity\Address $address = null;
/**
* @ORM\Id
*
* @ORM\ManyToOne(targetEntity=Household::class)
*
* @ORM\JoinColumn(nullable=false)
*/
private ?\Chill\PersonBundle\Entity\Household\Household $household = null;
/**
* @ORM\Id
*
* @ORM\ManyToOne(targetEntity=Person::class)
*
* @ORM\JoinColumn(nullable=false)
*/
private ?\Chill\PersonBundle\Entity\Person $person = null;
@@ -98,7 +103,7 @@ class PersonHouseholdAddress
* (this is not the startdate of the household, not
* the startdate of the address)
*/
public function getValidFrom(): ?DateTimeInterface
public function getValidFrom(): ?\DateTimeInterface
{
return $this->validFrom;
}
@@ -109,7 +114,7 @@ class PersonHouseholdAddress
* (this is not the enddate of the household, not
* the enddate of the address)
*/
public function getValidTo(): ?DateTimeImmutable
public function getValidTo(): ?\DateTimeImmutable
{
return $this->validTo;
}

View File

@@ -16,7 +16,9 @@ use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Entity
*
* @ORM\Table(name="chill_person_household_position")
*
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
* "household_position": Position::class
* })
@@ -25,33 +27,41 @@ class Position
{
/**
* @ORM\Column(type="boolean")
*
* @Serializer\Groups({ "read" })
*/
private bool $allowHolder = false;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?int $id = null;
/**
* @ORM\Column(type="json")
*
* @Serializer\Groups({"read", "docgen:read"})
*
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
*/
private array $label = [];
/**
* @ORM\Column(type="float")
*
* @Serializer\Groups({"read"})
*/
private float $ordering = 0.00;
/**
* @ORM\Column(type="boolean")
*
* @Serializer\Groups({"read"})
*/
private bool $shareHouseHold = true;

View File

@@ -17,15 +17,16 @@ use Doctrine\ORM\Mapping as ORM;
* MaritalStatus.
*
* @ORM\Entity
*
* @ORM\Table(name="chill_person_marital_status")
*
* @ORM\HasLifecycleCallbacks
*/
class MaritalStatus
{
/**
* @var string
*
* @ORM\Id
*
* @ORM\Column(type="string", length=7)
*/
private ?string $id;

View File

@@ -11,7 +11,6 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Entity;
use ArrayIterator;
use Chill\BudgetBundle\Entity\Charge;
use Chill\BudgetBundle\Entity\Resource;
use Chill\CalendarBundle\Entity\Calendar;
@@ -37,27 +36,23 @@ use Chill\PersonBundle\Validator\Constraints\Household\HouseholdMembershipSequen
use Chill\PersonBundle\Validator\Constraints\Person\Birthdate;
use Chill\PersonBundle\Validator\Constraints\Person\PersonHasCenter;
use DateTime;
use DateTimeImmutable;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping as ORM;
use Exception;
use libphonenumber\PhoneNumber;
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use UnexpectedValueException;
use function count;
use function in_array;
/**
* Person Class.
*
* @ORM\Entity
*
* @ORM\Table(name="chill_person_person",
* indexes={
*
* @ORM\Index(
* name="person_names",
* columns={"firstName", "lastName"}
@@ -67,11 +62,15 @@ use function in_array;
* columns={"birthdate"}
* )
* })
*
* @ORM\HasLifecycleCallbacks
*
* @DiscriminatorMap(typeProperty="type", mapping={
* "person": Person::class
* })
*
* @PersonHasCenter
*
* @HouseholdMembershipSequential(
* groups={"household_memberships"}
* )
@@ -94,8 +93,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* Accept receiving email.
*
* @var bool
*
* @ORM\Column(type="boolean", options={"default": false})
*/
private ?bool $acceptEmail = false;
@@ -103,8 +100,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* Accept short text message (aka SMS).
*
* @var bool
*
* @ORM\Column(type="boolean", options={"default": false})
*/
private ?bool $acceptSMS = false;
@@ -117,6 +112,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* @ORM\OneToMany(targetEntity=AccompanyingPeriodParticipation::class,
* mappedBy="person",
* cascade={"persist", "remove", "merge", "detach"})
*
* @ORM\OrderBy({"startDate": "DESC"})
*/
private Collection $accompanyingPeriodParticipations;
@@ -139,7 +135,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* @ORM\ManyToMany(
* targetEntity="Chill\MainBundle\Entity\Address",
* cascade={"persist", "remove", "merge", "detach"})
*
* @ORM\JoinTable(name="chill_person_persons_to_addresses")
*
* @ORM\OrderBy({"validFrom": "DESC"})
*/
private Collection $addresses;
@@ -159,12 +157,14 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* The person's birthdate.
*
* @ORM\Column(type="date", nullable=true)
*
* @Birthdate
*/
private ?\DateTime $birthdate = null;
/**
* @var Collection<Charge>
*
* @ORM\OneToMany(
* targetEntity=Charge::class,
* mappedBy="person"
@@ -173,7 +173,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
private Collection $budgetCharges;
/**
* @var Collection<Resource>
* @var Collection<resource>
*
* @ORM\OneToMany(
* targetEntity=Resource::class,
* mappedBy="person"
@@ -183,6 +184,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* @var Collection<int, Calendar>
*
* @ORM\ManyToMany(
* targetEntity="Chill\CalendarBundle\Entity\Calendar",
* mappedBy="persons"
@@ -214,7 +216,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* Array where customfield's data are stored.
*
*
* @ORM\Column(type="json")
*/
private ?array $cFData = null;
@@ -222,8 +223,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* The marital status of the person.
*
*
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Civility")
*
* @ORM\JoinColumn(nullable=true)
*/
private ?\Chill\MainBundle\Entity\Civility $civility = null;
@@ -231,7 +232,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* Contact information for contacting the person.
*
*
* @ORM\Column(type="text", nullable=true)
*/
private string $contactInfo = '';
@@ -239,10 +239,10 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* The person's country of birth.
*
*
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Country")
*
* sf4 check: option inversedBy="birthsIn" return error mapping !!
*
* @ORM\JoinColumn(nullable=true)
*/
private ?\Chill\MainBundle\Entity\Country $countryOfBirth = null;
@@ -254,6 +254,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* @ORM\ManyToOne(targetEntity=User::class)
*
* @ORM\JoinColumn(nullable=true)
*/
private ?\Chill\MainBundle\Entity\User $createdBy = null;
@@ -280,20 +281,21 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* The person's deathdate.
*
* @var DateTimeImmutable
*
* @ORM\Column(type="date_immutable", nullable=true)
*
* @Assert\Date
*
* @Assert\GreaterThanOrEqual(propertyPath="birthdate")
*
* @Assert\LessThanOrEqual("today")
*/
private ?DateTimeImmutable $deathdate = null;
private ?\DateTimeImmutable $deathdate = null;
/**
* The person's email.
*
*
* @ORM\Column(type="text", nullable=true)
*
* @Assert\Email()
*/
private string $email = '';
@@ -302,7 +304,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* The person's first name.
*
* @ORM\Column(type="string", length=255)
*
* @Assert\NotBlank(message="The firstname cannot be empty")
*
* @Assert\Length(
* max=255,
* )
@@ -320,8 +324,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* The person's gender.
*
*
* @ORM\Column(type="string", length=9, nullable=true)
*
* @Assert\NotNull(message="The gender must be set")
*/
private ?string $gender = null;
@@ -337,6 +341,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* Read-only field, computed by the database.
*
* @var Collection<PersonHouseholdAddress>
*
* @ORM\OneToMany(
* targetEntity=PersonHouseholdAddress::class,
* mappedBy="person"
@@ -358,7 +363,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* The person's id.
*
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
@@ -367,7 +374,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* The person's last name.
*
* @ORM\Column(type="string", length=255)
*
* @Assert\NotBlank(message="The lastname cannot be empty")
*
* @Assert\Length(
* max=255,
* )
@@ -377,8 +386,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* The marital status of the person.
*
*
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\MaritalStatus")
*
* @ORM\JoinColumn(nullable=true)
*/
private ?\Chill\PersonBundle\Entity\MaritalStatus $maritalStatus = null;
@@ -394,14 +403,14 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* The date of the last marital status change of the person.
*
* @ORM\Column(type="date", nullable=true)
*
* @Assert\Date
*/
private ?DateTime $maritalStatusDate = null;
private ?\DateTime $maritalStatusDate = null;
/**
* A remark over the person.
*
*
* @ORM\Column(type="text")
*/
private string $memo = ''; // TO-CHANGE in remark
@@ -410,6 +419,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* The person's mobile phone number.
*
* @PhonenumberConstraint(type="mobile")
*
* @ORM\Column(type="phone_number", nullable=true)
*/
private ?PhoneNumber $mobilenumber = null;
@@ -417,10 +427,10 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* The person's nationality.
*
*
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Country")
*
* sf4 check: option inversedBy="nationals" return error mapping !!
*
* @ORM\JoinColumn(nullable=true)
*/
private ?\Chill\MainBundle\Entity\Country $nationality = null;
@@ -428,8 +438,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* Number of children.
*
* @var int
*
* @ORM\Column(type="integer", nullable=true)
*/
private ?int $numberOfChildren = null;
@@ -443,6 +451,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* cascade={"persist", "remove", "merge", "detach"},
* orphanRemoval=true
* )
*
* @Assert\Valid(
* traverse=true,
* )
@@ -454,6 +463,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* targetEntity=AccompanyingPeriod::class,
* mappedBy="personLocation"
* )
*
* @var Collection<AccompanyingPeriod>
*/
private Collection $periodLocatedOn;
@@ -462,6 +472,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* The person's phonenumber.
*
* @ORM\Column(type="phone_number", nullable=true)
*
* @PhonenumberConstraint(
* type="landline",
* )
@@ -471,17 +482,16 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
/**
* The person's place of birth.
*
*
* @ORM\Column(type="string", length=255, name="place_of_birth")
*/
private string $placeOfBirth = '';
/**
*
* @deprecated
*
* @ORM\Column(type="boolean")
*/
private bool $proxyAccompanyingPeriodOpenState = false; //TO-DELETE ?
private bool $proxyAccompanyingPeriodOpenState = false; // TO-DELETE ?
/**
* @ORM\OneToMany(targetEntity=PersonResource::class, mappedBy="personOwner")
@@ -496,6 +506,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* @var Collection<Language>
*
* @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\Language")
*
* @ORM\JoinTable(
* name="persons_spoken_languages",
* joinColumns={@ORM\JoinColumn(name="person_id", referencedColumnName="id")},
@@ -539,9 +550,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
$this->centerHistory = new ArrayCollection();
}
/**
* @return string
*/
public function __toString(): string
{
return $this->getLabel();
@@ -616,13 +624,13 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* the person are not collapsing (i.e. have not shared days) or having
* a period after an open period.
*
* @return true | array True if the accompanying periods are not collapsing,
* an array with data for displaying the error
* @return true|array True if the accompanying periods are not collapsing,
* an array with data for displaying the error
*/
public function checkAccompanyingPeriodsAreNotCollapsing(): array|bool
{
$periods = $this->getAccompanyingPeriodsOrdered();
$periodsNbr = count($periods);
$periodsNbr = \count($periods);
$i = 0;
while ($periodsNbr - 1 > $i) {
@@ -661,9 +669,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
*
* To check if the Person and its accompanying period are consistent, use validation.
*
* @throws Exception if two lines of the accompanying period are open.
* @throws \Exception if two lines of the accompanying period are open
*/
public function close(?AccompanyingPeriod $accompanyingPeriod = null): void
public function close(AccompanyingPeriod $accompanyingPeriod = null): void
{
$this->proxyAccompanyingPeriodOpenState = false;
}
@@ -701,7 +709,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
}
}
if (0 < count($closeCandidates)) {
if (0 < \count($closeCandidates)) {
return $closeCandidates[0];
}
@@ -725,7 +733,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* * as participant, only for opened participation;
*
* @param bool $asParticipantOpen add participation which are still opened
* @param bool $asRequestor add accompanying period where the person is requestor
* @param bool $asRequestor add accompanying period where the person is requestor
*
* @return AccompanyingPeriod[]|Collection
*/
@@ -737,8 +745,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
if ($asParticipantOpen) {
foreach ($this->getAccompanyingPeriodParticipations()
->map(fn (AccompanyingPeriodParticipation $app) => $app->getAccompanyingPeriod())
as $period
->map(fn (AccompanyingPeriodParticipation $app) => $app->getAccompanyingPeriod()) as $period
) {
if (!$result->contains($period)) {
$result->add($period);
@@ -763,7 +770,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
): int {
// TODO should be optimized to avoid loading accompanying period ?
return $this->getAccompanyingPeriodInvolved($asParticipantOpen, $asRequestor)
->filter(fn (AccompanyingPeriod $p) => $p->getStep() !== AccompanyingPeriod::STEP_DRAFT)
->filter(fn (AccompanyingPeriod $p) => AccompanyingPeriod::STEP_DRAFT !== $p->getStep())
->count();
}
@@ -793,7 +800,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
$accompanyingPeriods = [];
foreach ($this->accompanyingPeriodParticipations as $participation) {
/** @var AccompanyingPeriodParticipation $participation */
/* @var AccompanyingPeriodParticipation $participation */
$accompanyingPeriods[] = $participation->getAccompanyingPeriod();
}
@@ -807,7 +814,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
{
$periods = $this->getAccompanyingPeriods();
//order by date :
// order by date :
usort($periods, static function ($a, $b) {
$dateA = $a->getOpeningDate();
$dateB = $b->getOpeningDate();
@@ -845,17 +852,17 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
*
* @deprecated since chill2.0, address is linked to the household. Use @see{Person::getCurrentHouseholdAddress}
*
* @throws Exception
* @throws \Exception
*/
public function getAddressAt(?DateTimeInterface $at = null): ?Address
public function getAddressAt(\DateTimeInterface $at = null): ?Address
{
$at ??= new DateTime('now');
$at ??= new \DateTime('now');
if ($at instanceof DateTimeImmutable) {
$at = DateTime::createFromImmutable($at);
if ($at instanceof \DateTimeImmutable) {
$at = \DateTime::createFromImmutable($at);
}
/** @var ArrayIterator $addressesIterator */
/** @var \ArrayIterator $addressesIterator */
$addressesIterator = $this->getAddresses()
->filter(static fn (Address $address): bool => $address->getValidFrom() <= $at)
->getIterator();
@@ -883,12 +890,12 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
*
* If the person has a deathdate, calculate the age at the deathdate.
*
* @param string $at A valid string to create a DateTime.
* @param string $at a valid string to create a DateTime
*/
public function getAge(string $at = 'now'): ?int
{
if ($this->birthdate instanceof DateTimeInterface) {
if ($this->deathdate instanceof DateTimeInterface) {
if ($this->birthdate instanceof \DateTimeInterface) {
if ($this->deathdate instanceof \DateTimeInterface) {
return (int) date_diff($this->birthdate, $this->deathdate)->format('%y');
}
@@ -903,7 +910,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->altNames;
}
public function getBirthdate(): ?DateTime
public function getBirthdate(): ?\DateTime
{
return $this->birthdate;
}
@@ -987,7 +994,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->countryOfBirth;
}
public function getCreatedAt(): ?DateTimeInterface
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
@@ -1015,7 +1022,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
public function getCurrentAccompanyingPeriods(): array
{
$currentAccompanyingPeriods = [];
$currentDate = new DateTime();
$currentDate = new \DateTime();
foreach ($this->accompanyingPeriodParticipations as $participation) {
$endDate = $participation->getEndDate();
@@ -1028,7 +1035,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $currentAccompanyingPeriods;
}
public function getCurrentHousehold(?DateTimeImmutable $at = null): ?Household
public function getCurrentHousehold(\DateTimeImmutable $at = null): ?Household
{
$participation = $this->getCurrentHouseholdParticipationShareHousehold($at);
@@ -1043,11 +1050,11 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* if the given date is 'now', use instead @see{getCurrentPersonAddress}, which is optimized on
* database side.
*/
public function getCurrentHouseholdAddress(?DateTimeImmutable $at = null): ?Address
public function getCurrentHouseholdAddress(\DateTimeImmutable $at = null): ?Address
{
if (
null === $at
|| $at->format('Ymd') === (new DateTime('today'))->format('Ymd')
|| $at->format('Ymd') === (new \DateTime('today'))->format('Ymd')
) {
return $this->currentPersonAddress instanceof PersonCurrentAddress
? $this->currentPersonAddress->getAddress() : null;
@@ -1077,11 +1084,11 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return null;
}
public function getCurrentHouseholdParticipationShareHousehold(?DateTimeImmutable $at = null): ?HouseholdMember
public function getCurrentHouseholdParticipationShareHousehold(\DateTimeImmutable $at = null): ?HouseholdMember
{
$criteria = new Criteria();
$expr = Criteria::expr();
$date = $at ?? new DateTimeImmutable('today');
$date = $at ?? new \DateTimeImmutable('today');
$datef = $date->format('Y-m-d');
if (
@@ -1121,7 +1128,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->currentPersonAddress->getAddress();
}
public function getDeathdate(): ?DateTimeInterface
public function getDeathdate(): ?\DateTimeInterface
{
return $this->deathdate;
}
@@ -1236,20 +1243,20 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
*/
public function getLabel()
{
return $this->getFirstName() . ' ' . $this->getLastName();
return $this->getFirstName().' '.$this->getLastName();
}
/**
* @deprecated Use @see{Person::getCurrentPersonAddress} or @see{Person::getCurrentHouseholdAddress} instead
*
* @throws Exception
*
* @return false|mixed|null
*
* @throws \Exception
*/
public function getLastAddress(?DateTime $from = null)
public function getLastAddress(\DateTime $from = null)
{
return $this->getCurrentHouseholdAddress(
null !== $from ? DateTimeImmutable::createFromMutable($from) : null
null !== $from ? \DateTimeImmutable::createFromMutable($from) : null
);
}
@@ -1268,7 +1275,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->maritalStatusComment;
}
public function getMaritalStatusDate(): ?DateTimeInterface
public function getMaritalStatusDate(): ?\DateTimeInterface
{
return $this->maritalStatusDate;
}
@@ -1298,7 +1305,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
*/
public function getOpenedAccompanyingPeriod(): ?AccompanyingPeriod
{
if ($this->isOpen() === false) {
if (false === $this->isOpen()) {
return null;
}
@@ -1324,7 +1331,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
$criteria = Criteria::create();
$criteria
->andWhere(Criteria::expr()->eq('endDate', null))
->orWhere(Criteria::expr()->gt('endDate', new DateTime('now')));
->orWhere(Criteria::expr()->gt('endDate', new \DateTime('now')));
return $this->getAccompanyingPeriodParticipations()
->matching($criteria)
@@ -1364,7 +1371,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->spokenLanguages;
}
public function getUpdatedAt(): ?DateTimeInterface
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
@@ -1374,7 +1381,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->updatedBy;
}
public function hasCurrentHouseholdAddress(?DateTimeImmutable $at = null): bool
public function hasCurrentHouseholdAddress(\DateTimeImmutable $at = null): bool
{
return null !== $this->getCurrentHouseholdAddress($at);
}
@@ -1390,7 +1397,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
foreach ($this->addresses as $ad) {
$validDate = $ad->getValidFrom()->format('Y-m-d');
if (in_array($validDate, $validYMDDates, true)) {
if (\in_array($validDate, $validYMDDates, true)) {
return true;
}
$validYMDDates[] = $validDate;
@@ -1461,7 +1468,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return false;
}
public function isSharingHousehold(?DateTimeImmutable $at = null): bool
public function isSharingHousehold(\DateTimeImmutable $at = null): bool
{
return null !== $this->getCurrentHousehold($at);
}
@@ -1490,7 +1497,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
$participation = $this->participationsContainAccompanyingPeriod($accompanyingPeriod);
if (!null === $participation) {
$participation->setEndDate(new DateTime());
$participation->setEndDate(new \DateTime());
$this->accompanyingPeriodParticipations->removeElement($participation);
}
}
@@ -1555,7 +1562,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
}
/**
* @param DateTime $birthdate
* @param \DateTime $birthdate
*/
public function setBirthdate($birthdate): self
{
@@ -1571,7 +1578,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
*/
public function setCenter(?Center $center): self
{
$modification = new DateTimeImmutable('now');
$modification = new \DateTimeImmutable('now');
foreach ($this->centerHistory as $centerHistory) {
if (null === $centerHistory->getEndDate()) {
@@ -1601,6 +1608,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
$this->centerHistory[] = $newCenterHistory;
$newCenterHistory->setPerson($this);
}
return $this;
}
@@ -1611,7 +1619,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this;
}
public function setCivility(?Civility $civility = null): self
public function setCivility(Civility $civility = null): self
{
$this->civility = $civility;
@@ -1629,14 +1637,14 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this;
}
public function setCountryOfBirth(?Country $countryOfBirth = null): self
public function setCountryOfBirth(Country $countryOfBirth = null): self
{
$this->countryOfBirth = $countryOfBirth;
return $this;
}
public function setCreatedAt(DateTimeInterface $datetime): self
public function setCreatedAt(\DateTimeInterface $datetime): self
{
$this->createdAt = $datetime;
@@ -1650,7 +1658,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this;
}
public function setDeathdate(?DateTimeInterface $deathdate): self
public function setDeathdate(?\DateTimeInterface $deathdate): self
{
$this->deathdate = $deathdate;
@@ -1699,7 +1707,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this;
}
public function setMaritalStatus(?MaritalStatus $maritalStatus = null): self
public function setMaritalStatus(MaritalStatus $maritalStatus = null): self
{
$this->maritalStatus = $maritalStatus;
@@ -1713,7 +1721,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this;
}
public function setMaritalStatusDate(?DateTimeInterface $maritalStatusDate): self
public function setMaritalStatusDate(?\DateTimeInterface $maritalStatusDate): self
{
$this->maritalStatusDate = $maritalStatusDate;
@@ -1740,7 +1748,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this;
}
public function setNationality(?Country $nationality = null): self
public function setNationality(Country $nationality = null): self
{
$this->nationality = $nationality;
@@ -1789,7 +1797,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this;
}
public function setUpdatedAt(DateTimeInterface $datetime): self
public function setUpdatedAt(\DateTimeInterface $datetime): self
{
$this->updatedAt = $datetime;
@@ -1810,7 +1818,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
}
$criteria = Criteria::create();
$now = new DateTimeImmutable('now');
$now = new \DateTimeImmutable('now');
$criteria->where(Criteria::expr()->lte('startDate', $now))
->andWhere(Criteria::expr()->orX(
Criteria::expr()->isNull('endDate'),
@@ -1822,7 +1830,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return match ($histories->count()) {
0 => null,
1 => $histories->first(),
default => throw new UnexpectedValueException('It should not contains more than one center at a time'),
default => throw new \UnexpectedValueException('It should not contains more than one center at a time'),
};
}

View File

@@ -13,7 +13,6 @@ namespace Chill\PersonBundle\Entity\Person;
use Chill\MainBundle\Entity\Center;
use Chill\PersonBundle\Entity\Person;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
/**
@@ -23,7 +22,9 @@ use Doctrine\ORM\Mapping as ORM;
* using a SQL view.
*
* @ORM\Entity(readOnly=true)
*
* @ORM\Table(name="view_chill_person_person_center_history_current")
*
* @psalm-internal Chill\PersonBundle\Entity
*/
class PersonCenterCurrent
@@ -36,10 +37,11 @@ class PersonCenterCurrent
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*/
private ?DateTimeImmutable $endDate = null;
private ?\DateTimeImmutable $endDate = null;
/**
* @ORM\Id
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
@@ -52,7 +54,7 @@ class PersonCenterCurrent
/**
* @ORM\Column(type="date_immutable", nullable=false)
*/
private DateTimeImmutable $startDate;
private \DateTimeImmutable $startDate;
/**
* Populate the properties person, center, start and end date from history.
@@ -75,7 +77,7 @@ class PersonCenterCurrent
return $this->center;
}
public function getEndDate(): ?DateTimeImmutable
public function getEndDate(): ?\DateTimeImmutable
{
return $this->endDate;
}
@@ -93,7 +95,7 @@ class PersonCenterCurrent
return $this->person;
}
public function getStartDate(): DateTimeImmutable
public function getStartDate(): \DateTimeImmutable
{
return $this->startDate;
}

View File

@@ -17,13 +17,13 @@ use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
use Chill\MainBundle\Entity\Center;
use Chill\PersonBundle\Entity\Person;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
/**
* Associate a Person with a Center. The association may change on date intervals.
*
* @ORM\Entity
*
* @ORM\Table(name="chill_person_person_center_history")
*/
class PersonCenterHistory implements TrackCreationInterface, TrackUpdateInterface
@@ -35,11 +35,13 @@ class PersonCenterHistory implements TrackCreationInterface, TrackUpdateInterfac
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*/
private ?DateTimeImmutable $endDate = null;
private ?\DateTimeImmutable $endDate = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
@@ -48,11 +50,11 @@ class PersonCenterHistory implements TrackCreationInterface, TrackUpdateInterfac
/**
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="centerHistory")
*/
private ?\Chill\PersonBundle\Entity\Person $person = null,
private ?Person $person = null,
/**
* @ORM\ManyToOne(targetEntity=Center::class)
*/
private ?\Chill\MainBundle\Entity\Center $center = null,
private ?Center $center = null,
/**
* @ORM\Column(type="date_immutable", nullable=false)
*/
@@ -64,7 +66,7 @@ class PersonCenterHistory implements TrackCreationInterface, TrackUpdateInterfac
return $this->center;
}
public function getEndDate(): ?DateTimeImmutable
public function getEndDate(): ?\DateTimeImmutable
{
return $this->endDate;
}
@@ -79,7 +81,7 @@ class PersonCenterHistory implements TrackCreationInterface, TrackUpdateInterfac
return $this->person;
}
public function getStartDate(): ?DateTimeImmutable
public function getStartDate(): ?\DateTimeImmutable
{
return $this->startDate;
}
@@ -91,7 +93,7 @@ class PersonCenterHistory implements TrackCreationInterface, TrackUpdateInterfac
return $this;
}
public function setEndDate(?DateTimeImmutable $endDate): self
public function setEndDate(?\DateTimeImmutable $endDate): self
{
$this->endDate = $endDate;
@@ -105,7 +107,7 @@ class PersonCenterHistory implements TrackCreationInterface, TrackUpdateInterfac
return $this;
}
public function setStartDate(?DateTimeImmutable $startDate): self
public function setStartDate(?\DateTimeImmutable $startDate): self
{
$this->startDate = $startDate;

View File

@@ -13,7 +13,6 @@ namespace Chill\PersonBundle\Entity\Person;
use Chill\MainBundle\Entity\Address;
use Chill\PersonBundle\Entity\Person;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
/**
@@ -26,6 +25,7 @@ use Doctrine\ORM\Mapping as ORM;
* household membership and address validity. See @see{PersonHouseholdAddress}
*
* @ORM\Entity(readOnly=true)
*
* @ORM\Table("view_chill_person_current_address")
*/
class PersonCurrentAddress
@@ -37,7 +37,9 @@ class PersonCurrentAddress
/**
* @ORM\Id
*
* @ORM\OneToOne(targetEntity=Person::class, inversedBy="currentPersonAddress")
*
* @ORM\JoinColumn(name="person_id", referencedColumnName="id")
*/
protected Person $person;
@@ -45,12 +47,12 @@ class PersonCurrentAddress
/**
* @ORM\Column(name="valid_from", type="date_immutable")
*/
protected DateTimeImmutable $validFrom;
protected \DateTimeImmutable $validFrom;
/**
* @ORM\Column(name="valid_to", type="date_immutable")
*/
protected ?DateTimeImmutable $validTo = null;
protected ?\DateTimeImmutable $validTo = null;
public function getAddress(): Address
{
@@ -66,7 +68,7 @@ class PersonCurrentAddress
* This date is the intersection of household membership
* and address validity.
*/
public function getValidFrom(): DateTimeImmutable
public function getValidFrom(): \DateTimeImmutable
{
return $this->validFrom;
}
@@ -75,7 +77,7 @@ class PersonCurrentAddress
* This date is the intersection of household membership
* and address validity.
*/
public function getValidTo(): ?DateTimeImmutable
public function getValidTo(): ?\DateTimeImmutable
{
return $this->validTo;
}

View File

@@ -26,7 +26,9 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
/**
* @ORM\Entity
*
* @ORM\Table(name="chill_person_resource")
*
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
* "personResource": personResource::class
* })
@@ -39,27 +41,34 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_")
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private CommentEmbeddable $comment;
/**
* @ORM\Column(type="text", nullable=true)
*
* @Groups({"read", "docgen:read"})
*/
private ?string $freeText = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Groups({"read", "docgen:read"})
*/
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity=PersonResourceKind::class, inversedBy="personResources")
*
* @ORM\JoinColumn(nullable=true)
*
* @Groups({"read", "docgen:read"})
*/
private ?PersonResourceKind $kind = null;
@@ -68,7 +77,9 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
* The person which host the owner of this resource.
*
* @ORM\ManyToOne(targetEntity=Person::class)
*
* @ORM\JoinColumn(nullable=true)
*
* @Groups({"read", "docgen:read"})
*/
private ?Person $person = null;
@@ -77,14 +88,18 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
* The person linked with this resource.
*
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="resources")
*
* @ORM\JoinColumn(nullable=false)
*
* @Groups({"read"})
*/
private ?Person $personOwner = null;
/**
* @ORM\ManyToOne(targetEntity=ThirdParty::class, inversedBy="personResources")
*
* @ORM\JoinColumn(nullable=true)
*
* @Groups({"read", "docgen:read"})
*/
private ?ThirdParty $thirdParty = null;

View File

@@ -16,14 +16,18 @@ use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Entity
*
* @ORM\Table(name="chill_person_resource_kind")
*/
class PersonResourceKind
{
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"docgen:read"})
*/
private ?int $id = null;
@@ -35,7 +39,9 @@ class PersonResourceKind
/**
* @ORM\Column(type="json", length=255)
*
* @Serializer\Groups({"docgen:read"})
*
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
*/
private array $title;

View File

@@ -16,20 +16,22 @@ use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Repository\ResidentialAddressRepository;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Context;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=ResidentialAddressRepository::class)
*
* @ORM\Table(name="chill_person_residential_address")
*/
class ResidentialAddress
{
/**
* @ORM\ManyToOne(targetEntity=Address::class)
*
* @ORM\JoinColumn(nullable=true)
*
* @Groups({"read"})
*/
private ?Address $address = null;
@@ -41,43 +43,53 @@ class ResidentialAddress
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*
* @Groups({"read"})
*/
private ?DateTimeImmutable $endDate = null;
private ?\DateTimeImmutable $endDate = null;
/**
* @ORM\ManyToOne(targetEntity=Person::class)
*
* @ORM\JoinColumn(nullable=true)
*
* @Groups({"read"})
*
* @Context(normalizationContext={"groups": {"minimal"}})
*/
private ?Person $hostPerson = null;
/**
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
*
* @ORM\JoinColumn(nullable=true)
*
* @Groups({"read"})
*/
private ?ThirdParty $hostThirdParty = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity=Person::class)
*
* @ORM\JoinColumn(nullable=false)
*/
private Person $person;
/**
* @ORM\Column(type="datetime_immutable")
*
* @Groups({"read"})
*/
private ?DateTimeImmutable $startDate = null;
private ?\DateTimeImmutable $startDate = null;
public function __construct()
{
@@ -94,7 +106,7 @@ class ResidentialAddress
return $this->comment;
}
public function getEndDate(): ?DateTimeImmutable
public function getEndDate(): ?\DateTimeImmutable
{
return $this->endDate;
}
@@ -119,7 +131,7 @@ class ResidentialAddress
return $this->person;
}
public function getStartDate(): ?DateTimeImmutable
public function getStartDate(): ?\DateTimeImmutable
{
return $this->startDate;
}
@@ -138,7 +150,7 @@ class ResidentialAddress
return $this;
}
public function setEndDate(?DateTimeImmutable $endDate): self
public function setEndDate(?\DateTimeImmutable $endDate): self
{
$this->endDate = $endDate;
@@ -166,7 +178,7 @@ class ResidentialAddress
return $this;
}
public function setStartDate(DateTimeImmutable $startDate): self
public function setStartDate(\DateTimeImmutable $startDate): self
{
$this->startDate = $startDate;

View File

@@ -18,31 +18,30 @@ use Symfony\Component\Serializer\Annotation\Groups;
* PersonAltName.
*
* @ORM\Table(name="chill_person_alt_name")
*
* @ORM\Entity
*/
class PersonAltName
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
/**
* @var string
*
* @ORM\Column(name="key", type="string", length=255)
*
* @Groups({"write"})
*/
private ?string $key = null;
/**
* @var string
*
* @ORM\Column(name="label", type="text")
*
* @Groups({"write"})
*/
private ?string $label = null;
@@ -121,7 +120,7 @@ class PersonAltName
/**
* @return $this
*/
public function setPerson(?Person $person = null)
public function setPerson(Person $person = null)
{
$this->person = $person;

View File

@@ -19,6 +19,7 @@ use Doctrine\ORM\Mapping as ORM;
* PersonNotDuplicate.
*
* @ORM\Table(name="chill_person_not_duplicate")
*
* @ORM\Entity
*/
class PersonNotDuplicate
@@ -31,10 +32,10 @@ class PersonNotDuplicate
/**
* The person's id.
*
* @var int
*
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
@@ -56,7 +57,7 @@ class PersonNotDuplicate
public function __construct()
{
$this->date = new DateTime();
$this->date = new \DateTime();
}
public function getDate()
@@ -84,7 +85,7 @@ class PersonNotDuplicate
return $this->user;
}
public function setDate(DateTime $date)
public function setDate(\DateTime $date)
{
$this->date = $date;
}

View File

@@ -19,8 +19,10 @@ use libphonenumber\PhoneNumber;
* Person Phones.
*
* @ORM\Entity
*
* @ORM\Table(name="chill_person_phone",
* indexes={
*
* @ORM\Index(name="phonenumber", columns={"phonenumber"})
* })
*/
@@ -29,7 +31,7 @@ class PersonPhone
/**
* @ORM\Column(type="datetime", nullable=false)
*/
private DateTime $date;
private \DateTime $date;
/**
* @ORM\Column(type="text", nullable=true)
@@ -38,7 +40,9 @@ class PersonPhone
/**
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
@@ -63,10 +67,10 @@ class PersonPhone
public function __construct()
{
$this->date = new DateTime();
$this->date = new \DateTime();
}
public function getDate(): DateTime
public function getDate(): \DateTime
{
return $this->date;
}
@@ -102,7 +106,7 @@ class PersonPhone
&& null === $this->getPhonenumber();
}
public function setDate(DateTime $date): void
public function setDate(\DateTime $date): void
{
$this->date = $date;
}

View File

@@ -17,7 +17,9 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
/**
* @ORM\Entity
*
* @ORM\Table(name="chill_person_relations")
*
* @DiscriminatorMap(typeProperty="type", mapping={
* "relation": Relation::class
* })
@@ -26,28 +28,36 @@ class Relation
{
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?int $id = null;
/**
* @ORM\Column(type="boolean", nullable=true)
*
* @Serializer\Groups({"read"})
*/
private bool $isActive = true;
/**
* @ORM\Column(type="json", nullable=true)
*
* @Serializer\Groups({"read"})
*
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
*/
private array $reverseTitle = [];
/**
* @ORM\Column(type="json", nullable=true)
*
* @Serializer\Groups({"read"})
*
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
*/
private array $title = [];

View File

@@ -16,8 +16,6 @@ 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;
use Doctrine\ORM\Mapping\DiscriminatorColumn;
use RuntimeException;
@@ -27,11 +25,15 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
*
* @ORM\Table(name="chill_person_relationships")
*
* @DiscriminatorColumn(name="relation_id", type="integer")
*
* @DiscriminatorMap(typeProperty="type", mapping={
* "relationship": Relationship::class
* })
*
* @RelationshipNoDuplicate
*/
class Relationship implements TrackCreationInterface, TrackUpdateInterface
@@ -39,52 +41,67 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\Column(type="datetime_immutable")
*/
private ?DateTimeImmutable $createdAt = null;
private ?\DateTimeImmutable $createdAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*
* @ORM\JoinColumn(nullable=false)
*/
private ?User $createdBy = null;
/**
* @ORM\ManyToOne(targetEntity=Person::class)
*
* @ORM\JoinColumn(nullable=false)
*
* @Assert\NotNull
*
* @Serializer\Groups({"read", "write"})
*/
private ?Person $fromPerson = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"read"})
*/
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity=Relation::class)
*
* @ORM\JoinColumn(nullable=false, name="relation_id", referencedColumnName="id")
*
* @Assert\NotNull
*
* @Serializer\Groups({"read", "write"})
*/
private ?Relation $relation = null;
/**
* @ORM\Column(type="boolean")
*
* @Assert\Type(
* type="bool",
* message="This must be of type boolean"
* )
*
* @Serializer\Groups({"read", "write"})
*/
private bool $reverse;
/**
* @ORM\ManyToOne(targetEntity=Person::class)
*
* @ORM\JoinColumn(nullable=false)
*
* @Assert\NotNull
*
* @Serializer\Groups({"read", "write"})
*/
private ?Person $toPerson = null;
@@ -92,14 +109,14 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private ?DateTimeImmutable $updatedAt = null;
private ?\DateTimeImmutable $updatedAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
private ?User $updatedBy = null;
public function getCreatedAt(): ?DateTimeImmutable
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
@@ -130,7 +147,7 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface
public function getOpposite(Person $counterpart): Person
{
if ($this->fromPerson !== $counterpart && $this->toPerson !== $counterpart) {
throw new RuntimeException('the counterpart is neither the from nor to person for this relationship');
throw new \RuntimeException('the counterpart is neither the from nor to person for this relationship');
}
if ($this->fromPerson === $counterpart) {
@@ -155,7 +172,7 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface
return $this->toPerson;
}
public function getUpdatedAt(): ?DateTimeImmutable
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
@@ -165,7 +182,7 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface
return $this->updatedBy;
}
public function setCreatedAt(DateTimeInterface $createdAt): self
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
@@ -207,7 +224,7 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface
return $this;
}
public function setUpdatedAt(?DateTimeInterface $updatedAt): self
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;

View File

@@ -19,7 +19,9 @@ 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
* })
@@ -33,26 +35,32 @@ class Evaluation
/**
* @ORM\Column(type="dateinterval", nullable=true, options={"default": null})
*
* @Serializer\Groups({"read"})
*/
private ?DateInterval $delay = null;
private ?\DateInterval $delay = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?int $id = null;
/**
* @ORM\Column(type="dateinterval", nullable=true, options={"default": null})
*
* @Serializer\Groups({"read"})
*/
private ?DateInterval $notificationDelay = null;
private ?\DateInterval $notificationDelay = null;
/**
* @var Collection<SocialAction>
*
* @ORM\ManyToMany(
* targetEntity=SocialAction::class,
* mappedBy="evaluations"
@@ -62,13 +70,16 @@ class Evaluation
/**
* @ORM\Column(type="json")
*
* @Serializer\Groups({"read", "docgen:read"})
*
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
*/
private array $title = [];
/**
* @ORM\Column(type="text", nullable=true)
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?string $url = null;
@@ -90,7 +101,7 @@ class Evaluation
return $this;
}
public function getDelay(): ?DateInterval
public function getDelay(): ?\DateInterval
{
return $this->delay;
}
@@ -100,7 +111,7 @@ class Evaluation
return $this->id;
}
public function getNotificationDelay(): ?DateInterval
public function getNotificationDelay(): ?\DateInterval
{
return $this->notificationDelay;
}
@@ -146,14 +157,14 @@ class Evaluation
return $this;
}
public function setDelay(?DateInterval $delay): self
public function setDelay(?\DateInterval $delay): self
{
$this->delay = $delay;
return $this;
}
public function setNotificationDelay(?DateInterval $notificationDelay): self
public function setNotificationDelay(?\DateInterval $notificationDelay): self
{
$this->notificationDelay = $notificationDelay;

View File

@@ -11,7 +11,6 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Entity\SocialWork;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@@ -19,7 +18,9 @@ use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Entity
*
* @ORM\Table(name="chill_person_social_work_goal")
*
* @Serializer\DiscriminatorMap(
* typeProperty="type",
* mapping={
@@ -36,28 +37,36 @@ class Goal
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?int $id = null;
/**
* @var Collection<Result>
*
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="goals")
*
* @ORM\JoinTable(name="chill_person_social_work_goal_result")
*/
private Collection $results;
/**
* @var Collection<SocialAction>
*
* @ORM\ManyToMany(targetEntity=SocialAction::class, mappedBy="goals")
*/
private Collection $socialActions;
/**
* @ORM\Column(type="json")
*
* @Serializer\Groups({"read", "docgen:read"})
*
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
*/
private array $title = [];
@@ -86,7 +95,7 @@ class Goal
return $this;
}
public function getDesactivationDate(): ?DateTimeInterface
public function getDesactivationDate(): ?\DateTimeInterface
{
return $this->desactivationDate;
}
@@ -131,7 +140,7 @@ class Goal
return $this;
}
public function setDesactivationDate(?DateTimeInterface $desactivationDate): self
public function setDesactivationDate(?\DateTimeInterface $desactivationDate): self
{
$this->desactivationDate = $desactivationDate;

View File

@@ -14,7 +14,6 @@ namespace Chill\PersonBundle\Entity\SocialWork;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkGoal;
use DateTime;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@@ -22,7 +21,9 @@ use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Entity
*
* @ORM\Table(name="chill_person_social_work_result")
*
* @Serializer\DiscriminatorMap(
* typeProperty="type",
* mapping={
@@ -34,12 +35,14 @@ class Result
{
/**
* @var Collection<AccompanyingPeriodWorkGoal>
*
* @ORM\ManyToMany(targetEntity=AccompanyingPeriodWorkGoal::class, mappedBy="results")
*/
private Collection $accompanyingPeriodWorkGoals;
/**
* @var Collection<AccompanyingPeriodWork>
*
* @ORM\ManyToMany(targetEntity=AccompanyingPeriodWork::class, mappedBy="results")
*/
private Collection $accompanyingPeriodWorks;
@@ -47,31 +50,38 @@ class Result
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?DateTime $desactivationDate = null;
private ?\DateTime $desactivationDate = null;
/**
* @var Collection<Goal>
*
* @ORM\ManyToMany(targetEntity=Goal::class, mappedBy="results")
*/
private Collection $goals;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?int $id = null;
/**
* @var Collection<SocialAction>
*
* @ORM\ManyToMany(targetEntity=SocialAction::class, mappedBy="results")
*/
private Collection $socialActions;
/**
* @ORM\Column(type="json")
*
* @Serializer\Groups({"read", "docgen:read"})
*
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
*/
private array $title = [];
@@ -136,7 +146,7 @@ class Result
return $this->accompanyingPeriodWorks;
}
public function getDesactivationDate(): ?DateTimeInterface
public function getDesactivationDate(): ?\DateTimeInterface
{
return $this->desactivationDate;
}
@@ -195,7 +205,7 @@ class Result
return $this;
}
public function setDesactivationDate(?DateTimeInterface $desactivationDate): self
public function setDesactivationDate(?\DateTimeInterface $desactivationDate): self
{
$this->desactivationDate = $desactivationDate;

View File

@@ -12,7 +12,6 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Entity\SocialWork;
use DateInterval;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ReadableCollection;
@@ -21,7 +20,9 @@ use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Entity
*
* @ORM\Table(name="chill_person_social_action")
*
* @Serializer\DiscriminatorMap(
* typeProperty="type",
* mapping={
@@ -33,6 +34,7 @@ class SocialAction
{
/**
* @var Collection<SocialAction>
*
* @ORM\OneToMany(targetEntity=SocialAction::class, mappedBy="parent")
*/
private Collection $children;
@@ -49,21 +51,27 @@ class SocialAction
/**
* @var Collection<Evaluation>
*
* @ORM\ManyToMany(targetEntity=Evaluation::class, inversedBy="socialActions")
*
* @ORM\JoinTable(name="chill_person_social_work_evaluation_action")
*/
private Collection $evaluations;
/**
* @var Collection<Goal>
*
* @ORM\ManyToMany(targetEntity=Goal::class, inversedBy="socialActions")
*
* @ORM\JoinTable(name="chill_person_social_action_goal")
*/
private Collection $goals;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
@@ -85,7 +93,9 @@ class SocialAction
/**
* @var Collection<Result>
*
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="socialActions")
*
* @ORM\JoinTable(name="chill_person_social_action_result")
*/
private Collection $results;
@@ -187,12 +197,12 @@ class SocialAction
return $this->children;
}
public function getDefaultNotificationDelay(): ?DateInterval
public function getDefaultNotificationDelay(): ?\DateInterval
{
return $this->defaultNotificationDelay;
}
public function getDesactivationDate(): ?DateTimeInterface
public function getDesactivationDate(): ?\DateTimeInterface
{
return $this->desactivationDate;
}
@@ -369,14 +379,14 @@ class SocialAction
return $this;
}
public function setDefaultNotificationDelay(DateInterval $defaultNotificationDelay): self
public function setDefaultNotificationDelay(\DateInterval $defaultNotificationDelay): self
{
$this->defaultNotificationDelay = $defaultNotificationDelay;
return $this;
}
public function setDesactivationDate(?DateTimeInterface $desactivationDate): self
public function setDesactivationDate(?\DateTimeInterface $desactivationDate): self
{
$this->desactivationDate = $desactivationDate;

View File

@@ -11,7 +11,6 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Entity\SocialWork;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@@ -20,7 +19,9 @@ use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity
*
* @ORM\Table(name="chill_person_social_issue")
*
* @DiscriminatorMap(typeProperty="type", mapping={
* "social_issue": SocialIssue::class
* })
@@ -29,6 +30,7 @@ class SocialIssue
{
/**
* @var Collection<SocialIssue>
*
* @ORM\OneToMany(targetEntity=SocialIssue::class, mappedBy="parent")
*/
private Collection $children;
@@ -40,7 +42,9 @@ class SocialIssue
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
@@ -57,12 +61,14 @@ class SocialIssue
/**
* @var Collection<SocialAction>
*
* @ORM\OneToMany(targetEntity=SocialAction::class, mappedBy="issue")
*/
private Collection $socialActions;
/**
* @ORM\Column(type="json")
*
* @Groups({"read"})
*/
private array $title = [];
@@ -76,7 +82,6 @@ class SocialIssue
/**
* @internal use @see{SocialIssue::setParent} instead
*
*
* @return $this
*/
public function addChild(self $child): self
@@ -163,7 +168,7 @@ class SocialIssue
return $this->children;
}
public function getDesactivationDate(): ?DateTimeInterface
public function getDesactivationDate(): ?\DateTimeInterface
{
return $this->desactivationDate;
}
@@ -255,7 +260,7 @@ class SocialIssue
/**
* @return Collection<SocialAction> All the descendant social actions of all
* the descendants of the entity
* the descendants of the entity
*/
public function getRecursiveSocialActions(): Collection
{
@@ -336,7 +341,7 @@ class SocialIssue
return $this;
}
public function setDesactivationDate(?DateTimeInterface $desactivationDate): self
public function setDesactivationDate(?\DateTimeInterface $desactivationDate): self
{
$this->desactivationDate = $desactivationDate;