private function getStateShape(State $state) { switch ($state->getType()) { case State::TYPE_INITIAL: return 'doublecircle'; default: return 'circle'; } }
public function getNodeAttributes($attributes, \Finite\State\StateInterface $state, \Finite\StateMachine\StateMachineInterface $stateMachine) { $props = $state->getProperties(); if (count($props) > 0) { foreach (array_keys($props) as $prop) { $attributes['label'] .= "\\n* " . $prop; } } return $attributes; }
/** * {@inheritdoc} * * @throws Exception\StateException */ public function apply($transitionName, array $parameters = array()) { $transition = $this->getTransition($transitionName); $event = new TransitionEvent($this->getCurrentState(), $transition, $this, $parameters); if (!$this->can($transition, $parameters)) { throw new Exception\StateException(sprintf('The "%s" transition can not be applied to the "%s" state of object "%s" with graph "%s".', $transition->getName(), $this->currentState->getName(), get_class($this->getObject()), $this->getGraph())); } $this->dispatchTransitionEvent($transition, $event, FiniteEvents::PRE_TRANSITION); $returnValue = $transition->process($this); $this->stateAccessor->setState($this->object, $transition->getState()); $this->currentState = $this->getState($transition->getState()); $this->dispatchTransitionEvent($transition, $event, FiniteEvents::POST_TRANSITION); return $returnValue; }
/** * @{inheritDoc} * * @throws Exception\StateException */ public function apply($transitionName) { $transition = $this->getTransition($transitionName); $event = new TransitionEvent($this->getCurrentState(), $transition, $this); if (!$this->can($transition)) { throw new Exception\StateException(sprintf('The "%s" transition can not be applied to the "%s" state.', $transition->getName(), $this->currentState->getName())); } $this->dispatcher->dispatch(FiniteEvents::PRE_TRANSITION, $event); $this->dispatcher->dispatch(FiniteEvents::PRE_TRANSITION . '.' . $transitionName, $event); $returnValue = $transition->process($this); $this->object->setFiniteState($transition->getState()); $this->currentState = $this->getState($transition->getState()); $this->dispatcher->dispatch(FiniteEvents::POST_TRANSITION, $event); $this->dispatcher->dispatch(FiniteEvents::POST_TRANSITION . '.' . $transitionName, $event); return $returnValue; }
/** * Returns the node label. * * @param \Finite\State\StateInterface $state * @return string */ private function getNodeLabel(StateInterface $state) { $id = $state->getName(); $props = $state->getProperties(); if (count($props) > 0 && $this->configuration->renderProperties()) { foreach (array_keys($props) as $prop) { $id .= "\\n* " . $prop; } } return $id; }
/** * @param StateInterface $state * @param StateMachineInterface $stateMachine * * @return array */ private function getDefaultNodeAttributes(StateInterface $state, StateMachineInterface $stateMachine) { return ['shape' => $state->getType() != StateInterface::TYPE_NORMAL ? 'doublecircle' : 'circle', 'label' => $state->getName()]; }