Exemplo n.º 1
0
 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;
 }
Exemplo n.º 3
0
 /**
  * {@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;
 }
Exemplo n.º 4
0
 /**
  * @{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;
 }
Exemplo n.º 5
0
 /**
  * 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;
 }
Exemplo n.º 6
0
 /**
  * @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()];
 }