Add Index Listener
This commit is contained in:
@@ -9,26 +9,32 @@ class MeilisearchEventMarkerListener
|
||||
{
|
||||
public function onParseTemplate(Template $template): void
|
||||
{
|
||||
// ✅ Nur Event-Reader
|
||||
if ($template->getName() !== 'mod_eventreader') {
|
||||
return;
|
||||
}
|
||||
|
||||
// ✅ Event kommt DIREKT aus dem Template
|
||||
if (
|
||||
!isset($GLOBALS['objEvent']) ||
|
||||
!$GLOBALS['objEvent'] instanceof CalendarEventsModel
|
||||
!isset($template->event) ||
|
||||
!$template->event instanceof CalendarEventsModel
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
$event = CalendarEventsModel::findByPk($GLOBALS['objEvent']->id);
|
||||
$event = $template->event;
|
||||
|
||||
if ($event === null) {
|
||||
$priority = (int) ($event->priority ?? 0);
|
||||
$keywords = trim((string) ($event->keywords ?? ''));
|
||||
|
||||
if ($priority <= 0 && $keywords === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
// ✅ In globale Marker schreiben (merge-fähig)
|
||||
$GLOBALS['MEILISEARCH_MARKERS']['event'] = [
|
||||
'priority' => (int) ($event->priority ?? 0),
|
||||
'keywords' => trim((string) ($event->keywords ?? '')),
|
||||
'priority' => $priority > 0 ? $priority : null,
|
||||
'keywords' => $keywords !== '' ? $keywords : null,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user