AbandonedCart::class, 'FirstPurchase' => FirstPurchase::class, 'PurchasedInCategory' => PurchasedInCategory::class, 'PurchasedProduct' => PurchasedProduct::class, ]; /** @var ContainerWrapper */ private $container; public function __construct( ContainerWrapper $container ) { $this->container = $container; } /** @return object|null */ public function createEvent(string $eventName) { $eventClass = self::EVENTS_MAP[$eventName] ?? null; try { return $eventClass ? $this->container->get($eventClass) : null; } catch (ServiceNotFoundException $e) { return null; } } }