public load ( Finite\StateMachine\StateMachineInterface $stateMachine ) | ||
$stateMachine | Finite\StateMachine\StateMachineInterface |
public function load(StateMachineInterface $stateMachine)
{
if (null === $this->callbackHandler) {
$this->callbackHandler = new CallbackHandler($stateMachine->getDispatcher());
}
if (null === $this->callbackBuilderFactory) {
$this->callbackBuilderFactory = new CallbackBuilderFactory();
}
if (!$stateMachine->hasStateAccessor()) {
$stateMachine->setStateAccessor(new PropertyPathStateAccessor($this->config['property_path']));
}
$stateMachine->setGraph($this->config['graph']);
$this->loadStates($stateMachine);
$this->loadTransitions($stateMachine);
$this->loadCallbacks($stateMachine);
}
public function testLoadWithProperties() { $sm = new StateMachine(); $this->object = new ArrayLoader(array('class' => 'Stateful1', 'states' => array('start' => array('type' => 'initial', 'properties' => array('foo' => true, 'bar' => false)), 'end' => array('type' => 'final')), 'transitions' => array('finish' => array('from' => array('middle'), 'to' => 'end', 'properties' => array('default' => 'default'), 'configure_properties' => function (OptionsResolver $optionsResolver) { $optionsResolver->setRequired('required'); }))), $this->callbackHandler); $this->object->load($sm); }