Skip to content

Commit

Permalink
events for intercepting algolia data
Browse files Browse the repository at this point in the history
  • Loading branch information
Skullbock committed Nov 2, 2021
1 parent 63cf536 commit f36534b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion plugin/src/AlgoliaSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,20 @@ private function algoliaData(\Item $item): ?array
}
}

$this->zoo->event->dispatcher->notify($this->zoo->event->create($item, 'algolia:data', ['data' => &$data]));

return $data;
}

private function elementValueFor(\Element $element, array $params)
{
$value = null;
$this->zoo->event->dispatcher->notify($this->zoo->event->create($element, 'algolia:beforeelementdata', ['value' => &$value]));

if ($value !== null) {
return $value;
}

if ($element instanceof \ElementItemName) {
return $element->getItem()->name;
}
Expand Down Expand Up @@ -337,7 +346,10 @@ private function elementValueFor(\Element $element, array $params)
return $value;
}

return null;
$value = null;
$this->zoo->event->dispatcher->notify($this->zoo->event->create($element, 'algolia:elementdata', ['value' => &$value]));

return $value;
}

protected function findMenuItem($type, $id, $lang)
Expand Down

0 comments on commit f36534b

Please sign in to comment.