addTransition() 공개 메소드

public addTransition ( string | Finite\Transition\TransitionInterface $transition, string | null $initialState = null, string | null $finalState = null )
$transition string | Finite\Transition\TransitionInterface
$initialState string | null
$finalState string | null
예제 #1
0
 /**
  * @param StateMachineInterface $stateMachine
  */
 private function loadTransitions(StateMachineInterface $stateMachine)
 {
     $resolver = new OptionsResolver();
     $resolver->setRequired(array('from', 'to'));
     $resolver->setOptional(array('guard'));
     $resolver->setNormalizers(array('from' => function (Options $options, $v) {
         return (array) $v;
     }, 'guard' => function (Options $options, $v) {
         return !isset($v) ? null : $v;
     }));
     foreach ($this->config['transitions'] as $transition => $config) {
         $config = $resolver->resolve($config);
         $stateMachine->addTransition(new Transition($transition, $config['from'], $config['to'], $config['guard']));
     }
 }
예제 #2
0
 /**
  * @param StateMachineInterface $stateMachine
  */
 private function loadTransitions(StateMachineInterface $stateMachine)
 {
     $resolver = new OptionsResolver();
     $resolver->setRequired(array('from', 'to'));
     $resolver->setDefaults(array('guard' => null, 'configure_properties' => null, 'properties' => array()));
     $resolver->setAllowedTypes('configure_properties', array('null', 'callable'));
     $resolver->setNormalizer('from', function (Options $options, $v) {
         return (array) $v;
     });
     $resolver->setNormalizer('guard', function (Options $options, $v) {
         return !isset($v) ? null : $v;
     });
     $resolver->setNormalizer('configure_properties', function (Options $options, $v) {
         $resolver = new OptionsResolver();
         $resolver->setDefaults($options['properties']);
         if (is_callable($v)) {
             $v($resolver);
         }
         return $resolver;
     });
     foreach ($this->config['transitions'] as $transition => $config) {
         $config = $resolver->resolve($config);
         $stateMachine->addTransition(new Transition($transition, $config['from'], $config['to'], $config['guard'], $config['configure_properties']));
     }
 }