public function getSupportedEventsFor(StateMachineInterface $state_machine, $state_name, $write_only = false) { $write_events = $this->getWriteEventNames(); return array_filter(array_keys($state_machine->getTransitions($state_name)), function ($event_name) use($write_events, $write_only) { if ($event_name === StateMachine::SEQ_TRANSITIONS_KEY) { return false; } if ($write_only && !in_array($event_name, $write_events)) { return false; } return true; }); }
/** * Creates an array of dot-graph edges that connect the (state)nodes of the dot-graph. * * @param StateMachineInterface $state_machine * * @return array An array of strings, that represent the particular dot-graph edges. */ protected function getEdges(StateMachineInterface $state_machine) { $edges = []; foreach ($state_machine->getTransitions() as $state_name => $state_transitions) { foreach ($state_transitions as $event_name => $transitions) { foreach ($transitions as $transition) { $edges[] = $this->createEdge($transition, $state_name, $event_name); } } } $state_name = $state_machine->getInitialState()->getName(); $edges[] = sprintf('0 -> %s [color="%s"]', $this->node_id_map[$state_name], $this->getStyle('edge.colors.default', self::EDGE_DEFAULT_COLOR)); return $edges; }