<?php
namespace Aqarmap\Bundle\ListingBundle\EventListener;
use Aqarmap\Bundle\ListingBundle\Event\ListingEvent;
use Aqarmap\Bundle\ListingBundle\Service\V4\CompoundAveragePriceService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class CompoundAveragePricePerMeterListener implements EventSubscriberInterface
{
public const PRIORITY_ONE = 1;
/**
* @var CompoundAveragePriceService
*/
private $compoundAveragePriceService;
public function __construct(CompoundAveragePriceService $compoundAveragePriceService)
{
$this->compoundAveragePriceService = $compoundAveragePriceService;
}
/**
* Calculate Average price per meter for compound units regarding property types.
*
* @param ListingEvent
*/
public function calculateAveragePricePerMeter(ListingEvent $event): void
{
$compound = $event->getListing()->getParent();
$this->compoundAveragePriceService->addSubscriber($compound);
}
/**
* @return array The event names to listen to
*/
public static function getSubscribedEvents()
{
return [
'aqarmap.project.calculate.average.pricePerMeter' => ['calculateAveragePricePerMeter', self::PRIORITY_ONE],
];
}
}