<?php
namespace App\UseCase\PaymentPercent\Event;
use App\UseCase\PaymentPercent\Calculate\PaymentPercentCalculateHandler;
use App\UseCase\Wage\WageCalculateHandler;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class EventSubscriber implements EventSubscriberInterface
{
public function __construct(
private PaymentPercentCalculateHandler $paymentPercentCalculateHandler,
private WageCalculateHandler $wageCalculateHandler,
) {}
public static function getSubscribedEvents(): array
{
return [
PaymentPercentagesChangeEvent::NAME => 'onChange',
];
}
/**
* После изменения условий процентных ставок - пересчитываем процент и зп
*
* @param PaymentPercentagesChangeEvent $event
*
* @return void
*/
public function onChange(PaymentPercentagesChangeEvent $event): void
{
$paymentPercent = $this->paymentPercentCalculateHandler->handleFromPercentages(
$event->getPercentages(),
$event->getReportingDate(),
);
// if ($paymentPercent) {
// $this->wageCalculateHandler->handleFromPaymentPercent($paymentPercent);
// }
}
}