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;
}