fromBusinessEvent example


    private function collectBusinessEvent(array &$eventsDoc): void
    {
        $context = Context::createDefaultContext();
        $businessEvents = $this->businessEventCollector->collect($context);
        $eventDoc = new ArrayWriter(self::EVENT_DESCRIPTIONS);

        foreach ($businessEvents as $event) {
            $eventDoc->ensure($event->getName());

            $eventsDoc[] = HookableEventDoc::fromBusinessEvent(
                $event,
                $this->hookableEventCollector->getPrivilegesFromBusinessEventDefinition($event),
                $eventDoc->get($event->getName())
            );
        }
    }

    /** * @param list<HookableEventDoc> $eventsDoc */
    private function collectEntityWrittenEvent(array &$eventsDoc): void
    {
/** * @internal */
class HookableBusinessEventTest extends TestCase
{
    use IntegrationTestBehaviour;

    public function testGetter(): void
    {
        $scalarEvent = new ScalarBusinessEvent();
        $event = HookableBusinessEvent::fromBusinessEvent(
            $scalarEvent,
            $this->getContainer()->get(BusinessEventEncoder::class)
        );

        static::assertEquals($scalarEvent->getName()$event->getName());
        $shopwareVersion = $this->getContainer()->getParameter('kernel.shopware_version');
        static::assertEquals($scalarEvent->getEncodeValues($shopwareVersion)$event->getWebhookPayload());
    }

    /** * @dataProvider getEventsWithoutPermissions */
        // we don't want to dispatch those to the webhooks         if ($event instanceof StorableFlow) {
            return [];
        }

        if ($event instanceof Hookable) {
            return [$event];
        }

        if ($event instanceof FlowEventAware) {
            return [
                HookableBusinessEvent::fromBusinessEvent($event$this->eventEncoder),
            ];
        }

        if ($event instanceof EntityWrittenContainerEvent) {
            return $this->wrapEntityWrittenEvent($event);
        }

        return [];
    }

    /** * @return Hookable[] */
Home | Imprint | This part of the site doesn't use cookies.