src/Aqarmap/Bundle/ListingBundle/EventListener/CompoundAveragePricePerMeterListener.php line 28

Open in your IDE?
  1. <?php
  2. namespace Aqarmap\Bundle\ListingBundle\EventListener;
  3. use Aqarmap\Bundle\ListingBundle\Event\ListingEvent;
  4. use Aqarmap\Bundle\ListingBundle\Service\V4\CompoundAveragePriceService;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class CompoundAveragePricePerMeterListener implements EventSubscriberInterface
  7. {
  8.     public const PRIORITY_ONE 1;
  9.     /**
  10.      * @var CompoundAveragePriceService
  11.      */
  12.     private $compoundAveragePriceService;
  13.     public function __construct(CompoundAveragePriceService $compoundAveragePriceService)
  14.     {
  15.         $this->compoundAveragePriceService $compoundAveragePriceService;
  16.     }
  17.     /**
  18.      * Calculate Average price per meter for compound units regarding property types.
  19.      *
  20.      * @param ListingEvent
  21.      */
  22.     public function calculateAveragePricePerMeter(ListingEvent $event): void
  23.     {
  24.         $compound $event->getListing()->getParent();
  25.         $this->compoundAveragePriceService->addSubscriber($compound);
  26.     }
  27.     /**
  28.      * @return array The event names to listen to
  29.      */
  30.     public static function getSubscribedEvents()
  31.     {
  32.         return [
  33.             'aqarmap.project.calculate.average.pricePerMeter' => ['calculateAveragePricePerMeter',  self::PRIORITY_ONE],
  34.         ];
  35.     }
  36. }