The getAllEvents
hook allows you to modify the result sets of calendar and
event modules. It passes the current result set, the IDs of the parent items
and the start and end time as arguments and expects a result set (array) as
return value.
array $events
Associative array of all events (grouped by date).
array $calendars
The IDs of calendars enabled in the front end module.
int $timeStart
The calendar period start date (e.g. if the user selected “current month”, it will contain the timestamp of 00:00:00 of the first day of the month).
int $timeEnd
The calendar period end date (e.g. if the user selected “current month”, it will contain the timestamp of 23:59:59 of the last day of the month).
\Contao\Module $module
The front end module instance executing this hook.
An array containing all the events, grouped by a time stamp.
// src/EventListener/GetAllEventsListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
use Contao\Module;
#[AsHook('getAllEvents')]
class GetAllEventsListener
{
public function __invoke(array $events, array $calendars, int $timeStart, int $timeEnd, Module $module): array
{
// Add events to $events or modify the array …
return $events;
}
}