<?php
namespace App\EventSubscribers\Main;
use App\Entity\Main\AffiliateNotificationConfig;
use App\Entity\Main\PackInterface;
use App\Entity\Main\PackProductInterface;
use App\Entity\Main\Product;
use App\Entity\Main\Shipping;
use App\Entity\Main\ShippingBatch;
use App\Entity\Main\UpsellCart;
use App\Entity\Main\User;
use App\Entity\Main\UserCreditNote;
use App\Events\Main\Cart\CartChargedBackEvent;
use App\Events\Main\Cart\CartCreatedEvent;
use App\Events\Main\Cart\CartCreditNoteUsedEvent;
use App\Events\Main\Cart\CartItemAddedEvent;
use App\Events\Main\Cart\CartItemQuantityUpdatedEvent;
use App\Events\Main\Cart\CartItemRemovedEvent;
use App\Events\Main\Cart\CartRefundedEvent;
use App\Events\Main\Cart\TransactionRefundedEvent;
use App\Events\Main\Coaching\CoachingClickedOffEvent;
use App\Events\Main\Coaching\CoachingClickedOnEvent;
use App\Services\CartManager;
use App\Services\AffiliateNotificationManager;
use App\Services\ReferralProgramManager;
use App\Services\TransactionManager;
use App\Services\UserCreditNoteManager;
use App\Services\UserManager;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
/**
* Class TransactionSubscriber
* @package App\EventSubscribers\Main
*/
class TransactionSubscriber implements EventSubscriberInterface
{
const
TRANSACTION_REFUND = 'transaction.refund'
;
private EntityManagerInterface $entityManager;
private TransactionManager $transactionManager;
public function __construct(
EntityManagerInterface $entityManager,
TransactionManager $transactionManager
) {
$this->entityManager = $entityManager;
$this->transactionManager = $transactionManager;
}
/**
* @return array
*/
public static function getSubscribedEvents()
{
return array(
self::TRANSACTION_REFUND => "transactionRefund"
);
}
/**
* @param TransactionRefundedEvent $event
*/
public function transactionRefund(TransactionRefundedEvent $event)
{
$transaction = $event->getTransaction();
$this->transactionManager->cancelShippingFromRefundedTransaction($transaction);
}
}