BeforeLoadStorableFlowDataEvent example

if ($id === null) {
            return null;
        }

        $criteria = new Criteria([$id]);

        return $this->loadCustomerGroup($criteria$storableFlow->getContext()$id);
    }

    private function loadCustomerGroup(Criteria $criteria, Context $context, string $id): ?CustomerGroupEntity
    {
        $event = new BeforeLoadStorableFlowDataEvent(
            CustomerGroupDefinition::ENTITY_NAME,
            $criteria,
            $context,
        );

        $this->dispatcher->dispatch($event$event->getName());

        $customerGroup = $this->customerGroupRepository->search($criteria$context)->get($id);

        if ($customerGroup) {
            /** @var CustomerGroupEntity $customerGroup */
            


        $criteria = new Criteria([$id]);

        return $this->loadCustomerRecovery($criteria$storableFlow->getContext()$id);
    }

    private function loadCustomerRecovery(Criteria $criteria, Context $context, string $id): ?CustomerRecoveryEntity
    {
        $criteria->addAssociation('customer.salutation');

        $event = new BeforeLoadStorableFlowDataEvent(
            CustomerRecoveryDefinition::ENTITY_NAME,
            $criteria,
            $context,
        );

        $this->dispatcher->dispatch($event$event->getName());

        $customerRecovery = $this->customerRecoveryRepository->search($criteria$context)->get($id);

        if ($customerRecovery) {
            /** @var CustomerRecoveryEntity $customerRecovery */
            


        $criteria = new Criteria([$id]);

        return $this->loadUserRecovery($criteria$storableFlow->getContext()$id);
    }

    private function loadUserRecovery(Criteria $criteria, Context $context, string $id): ?UserRecoveryEntity
    {
        $criteria->addAssociation('user');

        $event = new BeforeLoadStorableFlowDataEvent(
            UserRecoveryDefinition::ENTITY_NAME,
            $criteria,
            $context,
        );

        $this->dispatcher->dispatch($event$event->getName());

        $user = $this->userRecoveryRepository->search($criteria$context)->get($id);

        if ($user) {
            /** @var UserRecoveryEntity $user */
            
/** * @internal * * @covers \Shopware\Core\Content\Flow\Events\BeforeLoadStorableFlowDataEvent */
#[Package('business-ops')] class BeforeLoadStorableFlowDataEventTest extends TestCase
{
    public function testGetters(): void
    {
        $event = new BeforeLoadStorableFlowDataEvent(
            'entity_name',
            new Criteria(),
            Context::createDefaultContext()
        );

        static::assertIsString($event->getName());
        static::assertSame('entity_name', $event->getEntityName());
        static::assertSame('flow.storer.entity_name.criteria.event', $event->getName());

        static::assertInstanceOf(Criteria::class$event->getCriteria());
        static::assertInstanceOf(Context::class$event->getContext());
    }


        $criteria = new Criteria([$id]);

        return $this->loadCustomer($criteria$storableFlow->getContext()$id);
    }

    private function loadCustomer(Criteria $criteria, Context $context, string $id): ?CustomerEntity
    {
        $criteria->addAssociation('salutation');

        $event = new BeforeLoadStorableFlowDataEvent(
            CustomerDefinition::ENTITY_NAME,
            $criteria,
            $context,
        );

        $this->dispatcher->dispatch($event$event->getName());

        $customer = $this->customerRepository->search($criteria$context)->get($id);

        if ($customer) {
            /** @var CustomerEntity $customer */
            
if ($id === null) {
            return null;
        }

        $criteria = new Criteria([$id]);

        return $this->loadNewsletterRecipient($criteria$storableFlow->getContext()$id);
    }

    private function loadNewsletterRecipient(Criteria $criteria, Context $context, string $id): ?NewsletterRecipientEntity
    {
        $event = new BeforeLoadStorableFlowDataEvent(
            NewsletterRecipientDefinition::ENTITY_NAME,
            $criteria,
            $context,
        );

        $this->dispatcher->dispatch($event$event->getName());

        $newsletterRecipient = $this->newsletterRecipientRepository->search($criteria$context)->get($id);

        if ($newsletterRecipient) {
            /** @var NewsletterRecipientEntity $newsletterRecipient */
            
if ($id === null) {
            return null;
        }

        $criteria = new Criteria([$id]);

        return $this->loadOrderTransaction($criteria$storableFlow->getContext()$id);
    }

    private function loadOrderTransaction(Criteria $criteria, Context $context, string $id): ?OrderTransactionEntity
    {
        $event = new BeforeLoadStorableFlowDataEvent(
            OrderTransactionDefinition::ENTITY_NAME,
            $criteria,
            $context,
        );

        $this->dispatcher->dispatch($event$event->getName());

        $orderTransaction = $this->orderTransactionRepository->search($criteria$context)->get($id);

        if ($orderTransaction) {
            /** @var OrderTransactionEntity $orderTransaction */
            


        $criteria = new Criteria([$id]);

        return $this->loadProduct($criteria$storableFlow->getContext()$id);
    }

    private function loadProduct(Criteria $criteria, Context $context, string $id): ?ProductEntity
    {
        $context->setConsiderInheritance(true);

        $event = new BeforeLoadStorableFlowDataEvent(
            ProductDefinition::ENTITY_NAME,
            $criteria,
            $context,
        );

        $this->dispatcher->dispatch($event$event->getName());

        /** @var ProductEntity|null $product */
        $product = $this->productRepository->search($criteria$context)->get($id);

        return $product;
    }
'transactions.stateMachineState',
            'transactions.paymentMethod',
            'deliveries.stateMachineState',
            'currency',
            'addresses.country',
            'tags',
            'documents',
        ]);

        $criteria->getAssociation('transactions')->addSorting(new FieldSorting('createdAt'));

        $event = new BeforeLoadStorableFlowDataEvent(
            OrderDefinition::ENTITY_NAME,
            $criteria,
            $context,
        );

        $this->dispatcher->dispatch($event$event->getName());

        $order = $this->orderRepository->search($criteria$context)->get($orderId);

        if ($order) {
            /** @var OrderEntity $order */
            
Home | Imprint | This part of the site doesn't use cookies.