src/Aqarmap/Bundle/ListingBundle/EventListener/ListingRejectedListener.php line 25
<?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
{
public function __construct(private readonly ListingRateService $listingRateService, private readonly 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(): array
{
return [
'aqarmap.listing_got_rejected' => 'onRejection',
];
}
}