getFromStateMachineState example

$stateFieldName,
            $context
        );

        $transitionsJson = [];
        /** @var StateMachineTransitionEntity $transition */
        foreach ($availableTransitions as $transition) {
            $transitionsJson[] = [
                'name' => $transition->getToStateMachineState()->getName(),
                'technicalName' => $transition->getToStateMachineState()->getTechnicalName(),
                'actionName' => $transition->getActionName(),
                'fromStateName' => $transition->getFromStateMachineState()->getTechnicalName(),
                'toStateName' => $transition->getToStateMachineState()->getTechnicalName(),
                'url' => $this->generateUrl('api.state_machine.transition_state', [
                    'entityName' => $entityName,
                    'entityId' => $entityId,
                    'version' => $request->attributes->get('version'),
                    'transition' => $transition->getActionName(),
                ]),
            ];
        }

        return new JsonResponse([
            

    private function findEdges(StateMachineEntity $stateMachine): array
    {
        $edges = [];
        $transitions = $stateMachine->getTransitions();
        if ($transitions === null) {
            return $edges;
        }

        foreach ($transitions as $transition) {
            $fromStateMachineState = $transition->getFromStateMachineState();
            $toStateMachineState = $transition->getToStateMachineState();
            if ($fromStateMachineState === null || $toStateMachineState === null) {
                continue;
            }
            $edges[$fromStateMachineState->getName()][] = [
                'name' => $transition->getActionName(),
                'to' => $toStateMachineState->getName(),
            ];
        }

        return $edges;
    }

        $stateMachine = $this->getStateMachine($stateMachineName$context);

        $stateMachineTransitions = $stateMachine->getTransitions();
        if ($stateMachineTransitions === null) {
            return [];
        }

        $transitions = [];
        foreach ($stateMachineTransitions as $transition) {
            /** @var StateMachineStateEntity $fromState */
            $fromState = $transition->getFromStateMachineState();
            if ($fromState->getId() === $fromStateId) {
                $transitions[] = $transition;
            }
        }

        return $transitions;
    }

    /** * @throws StateMachineException * @throws IllegalTransitionException * @throws UnnecessaryTransitionException * @throws InconsistentCriteriaIdsException */
Home | Imprint | This part of the site doesn't use cookies.