src/Aqarmap/Bundle/MainBundle/EventListener/ElasticaPopulateSubscriber.php line 22

Open in your IDE?
  1. <?php
  2. namespace Aqarmap\Bundle\MainBundle\EventListener;
  3. use FOS\ElasticaBundle\Persister\Event\Events;
  4. use FOS\ElasticaBundle\Persister\Event\PrePersistEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class ElasticaPopulateSubscriber implements EventSubscriberInterface
  7. {
  8.     public static function getSubscribedEvents(): array
  9.     {
  10.         return [Events::PRE_PERSIST => 'onPrePersist'];
  11.     }
  12.     /**
  13.      * Workaround to fix the error "Overall reply time (180 seconds) has been exceeded." while populating elastic
  14.      * using Enqueue.
  15.      *
  16.      * Ref: https://github.com/FriendsOfSymfony/FOSElasticaBundle/issues/1453
  17.      */
  18.     public function onPrePersist(PrePersistEvent $event): void
  19.     {
  20.         $options $event->getOptions();
  21.         $options array_replace($options, [
  22.             'limit_overall_reply_time' => 90 60 60// sec ( 90 minutes ... )
  23.         ]);
  24.         $event->setOptions($options);
  25.     }
  26. }