<?php
namespace Wabs\ProductPreorder\Subscriber;
use Shopware\Core\Framework\Event\BusinessEventCollector;
use Shopware\Core\Framework\Event\BusinessEventCollectorEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Wabs\ProductPreorder\Core\Checkout\Order\Event\PreorderPriceAdjustedEvent;
class BusinessEventCollectorSubscriber implements EventSubscriberInterface
{
private BusinessEventCollector $businessEventCollector;
public function __construct(BusinessEventCollector $businessEventCollector) {
$this->businessEventCollector = $businessEventCollector;
}
public static function getSubscribedEvents()
{
return [
BusinessEventCollectorEvent::NAME => ['onAddExampleEvent', 1000],
];
}
public function onAddExampleEvent(BusinessEventCollectorEvent $event): void
{
$collection = $event->getCollection();
$definition = $this->businessEventCollector->define(PreorderPriceAdjustedEvent::class);
if (!$definition) {
return;
}
$collection->set($definition->getName(), $definition);
}
}