public function getLoaderData($machine)
{
$rows = $this->getTransitions($machine);
$output = array();
// array for local caching of states
$states = array();
foreach ($rows as $row) {
$state_from = $row['state_from'];
$state_to = $row['state_to'];
// create the 'from' state
if (isset($states[$state_from])) {
$from = $states[$state_from];
} else {
$from = new State($row['state_from'], $row['state_from_type'], $row['state_from_entry_command'], $row['state_from_exit_command']);
$from->setDescription($row['state_from_description']);
}
// cache the 'from' state for the next iterations
$states[$from->getName()] = $from;
// create the 'to' state
if (isset($states[$state_to])) {
$to = $states[$state_to];
} else {
$to = new State($row['state_to'], $row['state_to_type'], $row['state_to_entry_command'], $row['state_to_exit_command']);
$to->setDescription($row['state_to_description']);
}
// cache to 'to' state for the next iterations
$states[$to->getName()] = $to;
// build the transition
$transition = new Transition($from, $to, $row['event'], $row['rule'], $row['command']);
$transition->setDescription($row['transition_description']);
$output[] = $transition;
}
return $output;
}