getFromPlace example

public function fillCustomerMetaDataFields(StateMachineTransitionEvent $event): void
    {
        if ($event->getContext()->getVersionId() !== Defaults::LIVE_VERSION) {
            return;
        }

        if ($event->getEntityName() !== 'order') {
            return;
        }

        if ($event->getToPlace()->getTechnicalName() !== OrderStates::STATE_COMPLETED && $event->getFromPlace()->getTechnicalName() !== OrderStates::STATE_COMPLETED) {
            return;
        }

        $this->updateCustomer([$event->getEntityId()]);
    }

    public function deleteOrder(PreWriteValidationEvent $event): void
    {
        if ($event->getContext()->getVersionId() !== Defaults::LIVE_VERSION) {
            return;
        }

        
static::assertNotNull($firstTransaction->getStateMachineState());
        static::assertNotNull($lastTransaction->getStateMachineState());
        static::assertSame('cancelled', $firstTransaction->getStateMachineState()->getTechnicalName());
        static::assertSame('open', $lastTransaction->getStateMachineState()->getTechnicalName());

        static::assertNotNull($this->paymentMethodChangedCriteriaEventResult);
        static::assertNotNull($this->paymentMethodChangedEventResult);
        static::assertSame($lastTransaction->getId()$this->paymentMethodChangedEventResult->getOrderTransaction()->getId());
        static::assertNotNull($this->transactionStateEventResult);
        static::assertSame($firstTransaction->getId()$this->transactionStateEventResult->getEntityId());
        static::assertSame('open', $this->transactionStateEventResult->getFromPlace()->getTechnicalName());
        static::assertSame('cancelled', $this->transactionStateEventResult->getToPlace()->getTechnicalName());
    }

    public function testSetPaymentMethodOwnOrderOtherPaymentMethodCancelled(): void
    {
        $this->setFirstTransactionState($this->ids->get('order-1'));
        $this->sendValidRequest($this->ids->get('order-1')$this->getAvailablePaymentMethodId(1));
        $transactions = $this->getTransactions($this->ids->get('order-1'));
        static::assertCount(2, $transactions);
        $firstTransaction = $transactions->first();
        static::assertNotNull($firstTransaction);
        
return;
        }

        if ($event->getToPlace()->getTechnicalName() === OrderStates::STATE_COMPLETED) {
            $products = $this->getProductsOfOrder($event->getEntityId()$event->getContext());

            $this->updateStockAndSales($products, -1);

            return;
        }

        if ($event->getFromPlace()->getTechnicalName() === OrderStates::STATE_COMPLETED) {
            $products = $this->getProductsOfOrder($event->getEntityId()$event->getContext());

            $this->updateStockAndSales($products, +1);

            return;
        }

        if ($event->getToPlace()->getTechnicalName() === OrderStates::STATE_CANCELLED || $event->getFromPlace()->getTechnicalName() === OrderStates::STATE_CANCELLED) {
            $products = $this->getProductsOfOrder($event->getEntityId()$event->getContext());

            $ids = array_column($products, 'referenced_id');

            

    public function getAvailableTransitions(
        string $entityName,
        string $entityId,
        string $stateFieldName,
        Context $context
    ): array {
        $stateMachineName = $this->getStateField($stateFieldName$entityName)->getStateMachineName();
        $repository = $this->definitionRegistry->getRepository($entityName);
        $fromPlace = $this->getFromPlace($entityName$entityId$stateFieldName$context$repository);

        return $this->getAvailableTransitionsById($stateMachineName$fromPlace->getId()$context);
    }

    /** * @throws StateMachineException * @throws IllegalTransitionException * @throws InconsistentCriteriaIdsException * @throws DefinitionNotFoundException */
    public function transition(Transition $transition, Context $context): StateMachineStateCollection
    {
return;
        }

        if ($event->getContext()->getVersionId() !== Defaults::LIVE_VERSION) {
            return;
        }

        if ($event->getEntityName() !== 'order') {
            return;
        }

        if ($event->getFromPlace()->getTechnicalName() === OrderStates::STATE_CANCELLED) {
            $this->stockStorage->alter(
                array_map(
                    fn (array $item) => $this->changeset($item['id']$item['product_id'], 0, (int) $item['quantity']),
                    $this->fetchOrderLineItemsForOrder($event->getEntityId())
                ),
                $event->getContext()
            );

            return;
        }

        
Home | Imprint | This part of the site doesn't use cookies.