<?php
namespace Aqarmap\Bundle\MainBundle\EventListener;
use FOS\ElasticaBundle\Persister\Event\Events;
use FOS\ElasticaBundle\Persister\Event\PrePersistEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ElasticaPopulateSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [Events::PRE_PERSIST => 'onPrePersist'];
}
/**
* Workaround to fix the error "Overall reply time (180 seconds) has been exceeded." while populating elastic
* using Enqueue.
*
* Ref: https://github.com/FriendsOfSymfony/FOSElasticaBundle/issues/1453
*/
public function onPrePersist(PrePersistEvent $event): void
{
$options = $event->getOptions();
$options = array_replace($options, [
'limit_overall_reply_time' => 90 * 60 * 60, // sec ( 90 minutes ... )
]);
$event->setOptions($options);
}
}