src/AppBundle/EventSubscriber/HourlyRateSubscriber.php line 40

Open in your IDE?
  1. <?php
  2. namespace AppBundle\EventSubscriber;
  3. use AppBundle\Event\Contact\ContactApplyHourlyRateEvent;
  4. use AppBundle\Event\Matter\MatterApplyHourlyRateEvent;
  5. use AppBundle\Service\HourlyRateActionsPublisher;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. /**
  8.  * Class HourlyRateSubscriber
  9.  */
  10. class HourlyRateSubscriber implements EventSubscriberInterface
  11. {
  12.     /**
  13.      * @var HourlyRateActionsPublisher
  14.      */
  15.     private $hourlyRateActionsPublisher;
  16.     /**
  17.      * HourlyRateSubscriber constructor.
  18.      * @param HourlyRateActionsPublisher $hourlyRateActionsPublisher
  19.      */
  20.     public function __construct(HourlyRateActionsPublisher $hourlyRateActionsPublisher)
  21.     {
  22.         $this->hourlyRateActionsPublisher $hourlyRateActionsPublisher;
  23.     }
  24.     /**
  25.      * @param ContactApplyHourlyRateEvent $event
  26.      */
  27.     public function onContactApplyHourlyRate(ContactApplyHourlyRateEvent $event)
  28.     {
  29.         $this->hourlyRateActionsPublisher->applyHourlyRateForCustomer($event->getContact(), $event->getInitiator());
  30.     }
  31.     /**
  32.      * @param MatterApplyHourlyRateEvent $event
  33.      */
  34.     public function onMatterApplyHourlyRate(MatterApplyHourlyRateEvent $event)
  35.     {
  36.         $this->hourlyRateActionsPublisher->applyHourlyRateForMatter($event->getMatter(), $event->getInitiator(), $event->getActivityIds(), $event->isUpdateVat());
  37.     }
  38.     /**
  39.      * @{@inheritDoc}
  40.      */
  41.     public static function getSubscribedEvents()
  42.     {
  43.         return [
  44.             ContactApplyHourlyRateEvent::NAME => 'onContactApplyHourlyRate',
  45.             MatterApplyHourlyRateEvent::NAME => 'onMatterApplyHourlyRate',
  46.         ];
  47.     }
  48. }