<?php
namespace AppBundle\EventSubscriber;
use AppBundle\Event\Contact\ContactApplyHourlyRateEvent;
use AppBundle\Event\Matter\MatterApplyHourlyRateEvent;
use AppBundle\Service\HourlyRateActionsPublisher;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Class HourlyRateSubscriber
*/
class HourlyRateSubscriber implements EventSubscriberInterface
{
/**
* @var HourlyRateActionsPublisher
*/
private $hourlyRateActionsPublisher;
/**
* HourlyRateSubscriber constructor.
* @param HourlyRateActionsPublisher $hourlyRateActionsPublisher
*/
public function __construct(HourlyRateActionsPublisher $hourlyRateActionsPublisher)
{
$this->hourlyRateActionsPublisher = $hourlyRateActionsPublisher;
}
/**
* @param ContactApplyHourlyRateEvent $event
*/
public function onContactApplyHourlyRate(ContactApplyHourlyRateEvent $event)
{
$this->hourlyRateActionsPublisher->applyHourlyRateForCustomer($event->getContact(), $event->getInitiator());
}
/**
* @param MatterApplyHourlyRateEvent $event
*/
public function onMatterApplyHourlyRate(MatterApplyHourlyRateEvent $event)
{
$this->hourlyRateActionsPublisher->applyHourlyRateForMatter($event->getMatter(), $event->getInitiator(), $event->getActivityIds(), $event->isUpdateVat());
}
/**
* @{@inheritDoc}
*/
public static function getSubscribedEvents()
{
return [
ContactApplyHourlyRateEvent::NAME => 'onContactApplyHourlyRate',
MatterApplyHourlyRateEvent::NAME => 'onMatterApplyHourlyRate',
];
}
}