Hi everyone!
I'm trying to upgrade a small customization I made on the discussion list sorting to be handled correctly by the stable Flarum version.
Previously I had the following snippet that was doing the job just fine:
// extend.php
$events->subscribe(FilterDiscussionList::class);
use Flarum\Discussion\Event\Searching;
use Illuminate\Contracts\Events\Dispatcher;
class FilterDiscussionList
{
public function subscribe(Dispatcher $events)
{
$events->listen(Searching::class, [$this, 'myBeautifulFunctionHandler']);
}
public function myBeautifulFunctionHandler(Searching $event)
{
$ADMIN_BOT_ID = 1;
$query = $event->search->getQuery();
if (count($event->search->getActiveGambits()) > 0) {
return;
}
$query->where('last_posted_user_id', '<>', $ADMIN_BOT_ID);
}
}
I read that Searching
has been replaced by SimpleFlarumSearch
but I couldn't find any example on how to extend this new class. Could anyone help me on how to do that?