<?php
namespace Aqarmap\Bundle\ListingBundle\EventListener;
use Aqarmap\Bundle\ListingBundle\Event\ListingEvent;
use Aqarmap\Bundle\ListingBundle\Service\ListingManager;
use Aqarmap\Bundle\ListingBundle\Service\ListingRateService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ListingRejectedListener implements EventSubscriberInterface
{
/** @var ListingRateService */
private $listingRateService;
/**
* @var ListingManager
*/
private $listingManager;
public function __construct(ListingRateService $listingRateService, ListingManager $listingManager)
{
$this->listingRateService = $listingRateService;
$this->listingManager = $listingManager;
}
public function onRejection(ListingEvent $event): void
{
$listing = $event->getListing();
if ($listing->getDeletedAt()) {
$listing->setDeletedAt(null);
}
$this->listingRateService->markRateStatusRejected($listing);
$this->listingManager->updateRejectedAt($listing, new \DateTime('now'));
}
/**
* {@inheri tdoc}.
*/
public static function getSubscribedEvents()
{
return [
'aqarmap.listing_got_rejected' => 'onRejection',
];
}
}