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