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

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the FOSElasticaBundle package.
  4. *
  5. * (c) FriendsOfSymfony <http://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\IndexPopulateEvent;
  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. * @param Resetter $resetter
  28. */
  29. public function __construct(Resetter $resetter)
  30. {
  31. $this->resetter = $resetter;
  32. }
  33. /**
  34. * @param IndexPopulateEvent $event
  35. */
  36. public function onPostIndexPopulate(IndexPopulateEvent $event)
  37. {
  38. if (!$event->isReset()) {
  39. return;
  40. }
  41. $this->resetter->switchIndexAlias($event->getIndex(), $event->getOption('delete'));
  42. }
  43. }