Exemple #1
0
 /**
  * @see MetaborStd\Statemachine.TransitionInterface::isActive()
  */
 public function isActive($subject, \ArrayAccess $context, EventInterface $event = null)
 {
     if ($event) {
         $result = $event->getName() == $this->eventName;
     } else {
         $result = is_null($this->eventName);
     }
     if ($this->condition) {
         $result = $result && $this->condition->checkCondition($subject, $context);
     }
     return $result;
 }
Exemple #2
0
 /**
  * @param StateInterface     $sourceState
  * @param StateInterface     $targetState
  * @param string             $eventName
  * @param ConditionInterface $condition
  *
  * @return TransitionInterface
  */
 protected function findTransition(StateInterface $sourceState, StateInterface $targetState, $eventName = null, ConditionInterface $condition = null)
 {
     $conditionName = $condition ? $condition->getName() : null;
     /* @var $transition TransitionInterface */
     foreach ($sourceState->getTransitions() as $transition) {
         $hasSameTargetState = $transition->getTargetState() === $targetState;
         $hasSameCondition = $transition->getConditionName() == $conditionName;
         $hasSameEvent = $transition->getEventName() == $eventName;
         if ($hasSameTargetState && $hasSameCondition && $hasSameEvent) {
             return $transition;
         }
     }
 }
Exemple #3
0
 /**
  *
  * @see MetaborStd.NamedInterface::getName()
  */
 public function getName()
 {
     return 'not ( ' . $this->condition->getName() . ' )';
 }