vendor/friendsofsymfony/elastica-bundle/src/EventListener/PopulateListener.php line 37

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the FOSElasticaBundle package.
  4. *
  5. * (c) FriendsOfSymfony <https://friendsofsymfony.github.com/>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace FOS\ElasticaBundle\EventListener;
  11. use FOS\ElasticaBundle\Event\PostIndexPopulateEvent;
  12. use FOS\ElasticaBundle\Index\Resetter;
  13. /**
  14. * PopulateListener.
  15. *
  16. * @author Oleg Andreyev <oleg.andreyev@intexsys.lv>
  17. */
  18. class PopulateListener
  19. {
  20. /**
  21. * @var Resetter
  22. */
  23. private $resetter;
  24. /**
  25. * PopulateListener constructor.
  26. */
  27. public function __construct(Resetter $resetter)
  28. {
  29. $this->resetter = $resetter;
  30. }
  31. public function onPostIndexPopulate(PostIndexPopulateEvent $event): void
  32. {
  33. if (!$event->isReset()) {
  34. return;
  35. }
  36. $this->resetter->switchIndexAlias($event->getIndex(), $event->getOption('delete'));
  37. }
  38. }