OrderStateMachineStateChangeEvent example



    /** * @dataProvider genDocumentProvider */
    public function testGenerateDocument(string $documentType, string $documentRangerType, bool $autoGenInvoiceDoc = false, bool $multipleDoc = false): void
    {
        $context = Context::createDefaultContext();
        $customerId = $this->createCustomer();
        $order = $this->createOrder($customerId$context);

        $event = new OrderStateMachineStateChangeEvent('state_enter.order.state.in_progress', $order$context);
        $subscriber = new GenerateDocumentAction($this->documentGenerator, $this->logger);

        if ($multipleDoc) {
            $config = [
                'documentTypes' => [
                    [
                        'documentType' => $documentType,
                        'documentRangerType' => $documentRangerType,
                        'custom' => ['invoiceNumber' => '1100'],
                    ],
                    [
                        
$collection->set($name$definition);
            }
        }
    }

    /** * @throws OrderException */
    private function dispatchEvent(string $stateEventName, OrderEntity $order, Context $context): void
    {
        $this->eventDispatcher->dispatch(
            new OrderStateMachineStateChangeEvent($stateEventName$order$context),
            $stateEventName
        );
    }

    private function getContext(string $orderId, Context $context): Context
    {
        $order = $this->orderRepository->search(new Criteria([$orderId])$context)->first();

        if (!$order instanceof OrderEntity) {
            throw OrderException::orderNotFound($orderId);
        }

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