<?php
namespace CioApprovalThreshold\Subscriber;
use CioApprovalThreshold\Event\CancelApprovalRequestEvent;
use CioApprovalThreshold\Event\ReleaserHasToVerifyOrderEvent;
use CioApprovalThreshold\Event\RequestRevisionEvent;
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 => ['onBusinessEventCollectorEvent', 1000]
];
}
public function onBusinessEventCollectorEvent(BusinessEventCollectorEvent $event)
{
$collection = $event->getCollection();
$definition = $this->businessEventCollector->define(ReleaserHasToVerifyOrderEvent::class);
if (!$definition) {
return;
}
$collection->set($definition->getName(), $definition);
$definition = $this->businessEventCollector->define(RequestRevisionEvent::class);
if (!$definition) {
return;
}
$collection->set($definition->getName(), $definition);
$definition = $this->businessEventCollector->define(CancelApprovalRequestEvent::class);
if (!$definition) {
return;
}
$collection->set($definition->getName(), $definition);
}
}