mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
Add a mention on next calendars on search results
This commit is contained in:
@@ -129,6 +129,11 @@ class AccompanyingPeriod implements
|
||||
*/
|
||||
private ?Location $administrativeLocation = null;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Chill\CalendarBundle\Entity\Calendar", mappedBy="accompanyingPeriod")
|
||||
*/
|
||||
private Collection $calendars;
|
||||
|
||||
/**
|
||||
* @var DateTime
|
||||
*
|
||||
@@ -389,6 +394,7 @@ class AccompanyingPeriod implements
|
||||
public function __construct(?DateTime $dateOpening = null)
|
||||
{
|
||||
$this->setOpeningDate($dateOpening ?? new DateTime('now'));
|
||||
$this->calendars = new ArrayCollection();
|
||||
$this->participations = new ArrayCollection();
|
||||
$this->scopes = new ArrayCollection();
|
||||
$this->socialIssues = new ArrayCollection();
|
||||
@@ -612,6 +618,11 @@ class AccompanyingPeriod implements
|
||||
);
|
||||
}
|
||||
|
||||
public function getCalendars(): Collection
|
||||
{
|
||||
return $this->calendars;
|
||||
}
|
||||
|
||||
public function getCenter(): ?Center
|
||||
{
|
||||
if ($this->getPersons()->count() === 0) {
|
||||
@@ -765,6 +776,24 @@ class AccompanyingPeriod implements
|
||||
return 'none';
|
||||
}
|
||||
|
||||
public function getNextCalendarsForPerson(Person $person, $limit = 5): Collection
|
||||
{
|
||||
$today = new DateTimeImmutable('today');
|
||||
$criteria = Criteria::create()
|
||||
->where(Criteria::expr()->gte('startDate', $today))
|
||||
//->andWhere(Criteria::expr()->memberOf('persons', $person))
|
||||
->orderBy(['startDate' => 'DESC'])
|
||||
->setMaxResults($limit * 2);
|
||||
|
||||
return $this->calendars->matching($criteria)
|
||||
->matching(
|
||||
// due to a bug, filter two times
|
||||
Criteria::create()
|
||||
->where(Criteria::expr()->memberOf('persons', $person))
|
||||
->setMaxResults($limit)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get openingDate.
|
||||
*
|
||||
|
@@ -176,6 +176,14 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
*/
|
||||
private Collection $budgetResources;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\CalendarBundle\Entity\Calendar",
|
||||
* mappedBy="persons"
|
||||
* )
|
||||
*/
|
||||
private Collection $calendars;
|
||||
|
||||
/**
|
||||
* The person's center.
|
||||
*
|
||||
|
Reference in New Issue
Block a user