mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-03 21:34:59 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user