<?php
namespace B2bOffer\Subscriber;
use B2bOffer\Components\LineItemEdit\Events\LineItemEditedEvent;
use B2bOffer\Components\Offer\Events\OfferOrderedByCustomerEvent;
use B2bOffer\Components\Offer\Events\OfferRequestCreatedEvent;
use B2bOffer\Components\Offer\Events\OfferStatusUpdatedEvent;
use B2bOffer\Components\Offer\Events\OfferValidityExtensionRequestedEvent;
use B2bOffer\Components\Offer\Events\PdfOfferCreatedEvent;
use Shopware\Core\Framework\Event\BusinessEventCollector;
use Shopware\Core\Framework\Event\BusinessEventCollectorEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class BusinessEventCollectorSubscriber implements EventSubscriberInterface
{
private BusinessEventCollector $businessEventCollector;
public function __construct(BusinessEventCollector $businessEventCollector)
{
$this->businessEventCollector = $businessEventCollector;
}
public static function getSubscribedEvents(): array
{
return [
BusinessEventCollectorEvent::NAME => ['onAddB2bOfferBusinessEvents', 1000],
];
}
public function onAddB2bOfferBusinessEvents(BusinessEventCollectorEvent $event): void
{
$collection = $event->getCollection();
$definition = $this->businessEventCollector->define(PdfOfferCreatedEvent::class, PdfOfferCreatedEvent::EVENT_NAME);
$collection->set(PdfOfferCreatedEvent::EVENT_NAME, $definition);
$definition = $this->businessEventCollector->define(LineItemEditedEvent::class, LineItemEditedEvent::EVENT_NAME);
$collection->set(LineItemEditedEvent::EVENT_NAME, $definition);
$definition = $this->businessEventCollector->define(OfferRequestCreatedEvent::class, OfferRequestCreatedEvent::EVENT_NAME);
$collection->set(OfferRequestCreatedEvent::EVENT_NAME, $definition);
$definition = $this->businessEventCollector->define(OfferValidityExtensionRequestedEvent::class, OfferValidityExtensionRequestedEvent::EVENT_NAME);
$collection->set(OfferValidityExtensionRequestedEvent::EVENT_NAME, $definition);
$definition = $this->businessEventCollector->define(OfferStatusUpdatedEvent::class, OfferStatusUpdatedEvent::EVENT_NAME);
$collection->set(OfferStatusUpdatedEvent::EVENT_NAME, $definition);
$definition = $this->businessEventCollector->define(OfferOrderedByCustomerEvent::class, OfferOrderedByCustomerEvent::EVENT_NAME);
$collection->set(OfferOrderedByCustomerEvent::EVENT_NAME, $definition);
}
}