src/Aqarmap/Bundle/ListingBundle/EventListener/ListingRejectedListener.php line 25

  1. <?php
  2. namespace Aqarmap\Bundle\ListingBundle\EventListener;
  3. use Aqarmap\Bundle\ListingBundle\Event\ListingEvent;
  4. use Aqarmap\Bundle\ListingBundle\Service\ListingManager;
  5. use Aqarmap\Bundle\ListingBundle\Service\ListingRateService;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class ListingRejectedListener implements EventSubscriberInterface
  8. {
  9. public function __construct(private readonly ListingRateService $listingRateService, private readonly ListingManager $listingManager)
  10. {
  11. }
  12. public function onRejection(ListingEvent $event): void
  13. {
  14. $listing = $event->getListing();
  15. if ($listing->getDeletedAt()) {
  16. $listing->setDeletedAt(null);
  17. }
  18. $this->listingRateService->markRateStatusRejected($listing);
  19. $this->listingManager->updateRejectedAt($listing, new \DateTime('now'));
  20. }
  21. /**
  22. * {@inheri tdoc}.
  23. */
  24. public static function getSubscribedEvents(): array
  25. {
  26. return [
  27. 'aqarmap.listing_got_rejected' => 'onRejection',
  28. ];
  29. }
  30. }