<?php
namespace App\EventSubscriber;
use App\Event\ItemUpdatedEvent;
use App\Helper\UserHelper;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ItemUpdatedSubscriber implements EventSubscriberInterface
{
private UserHelper $userHelper;
public function __construct(
UserHelper $userHelper
) {
$this->userHelper = $userHelper;
}
public static function getSubscribedEvents()
{
return [
ItemUpdatedEvent::NAME => 'onUpdateItem'
];
}
public function onUpdateItem(ItemUpdatedEvent $itemUpdatedEvent)
{
$this->userHelper->recalculatePlan($itemUpdatedEvent->getItem()->getUser());
}
}