#[Route(path: '/api/_action/state-machine/{entityName}/{entityId}/state', name: 'api.state_machine.states', methods: ['GET'])]
public function getAvailableTransitions( Request
$request,
Context
$context,
string
$entityName,
string
$entityId ): JsonResponse
{ $stateFieldName =
(string) $request->query->
get('stateFieldName', 'stateId'
);
$availableTransitions =
$this->stateMachineRegistry->
getAvailableTransitions( $entityName,
$entityId,
$stateFieldName,
$context );
$transitionsJson =
[];
/** @var StateMachineTransitionEntity $transition */
foreach ($availableTransitions as $transition) { $transitionsJson[] =
[ 'name' =>
$transition->
getToStateMachineState()->
getName(),