/**
  * @param string $name name of state machine to build
  *
  * @return Workflux\StateMachine\StateMachineInterface
  */
 public function build($name)
 {
     if (!isset($this->state_machine_definitions[$name])) {
         throw new RuntimeError('State machine not configured: ' . $name);
     }
     // name is necessary as option here, as there may be multiple state machines in the definition xml file
     $builder = new XmlStateMachineBuilder(['name' => $name, 'state_machine_definition' => $this->state_machine_definitions], $this->service_locator);
     return $builder->build();
 }
 /**
  * Validate input and provide a state machine subject for the input value
  */
 protected function validate()
 {
     $success = parent::validate();
     if ($success) {
         $input = $this->getData('input');
         $subject = $this->getData($this->original_argument);
         $builder = new XmlStateMachineBuilder(['state_machine_definition' => $input, 'name' => $subject], $this->getContext()->getServiceLocator());
         $state_machine = $builder->build();
         $this->export($state_machine, $this->original_argument);
     }
     return $success;
 }
Example #3
0
 protected function getDefaultStateMachine()
 {
     $guard_stub = $this->createMock(GuardInterface::CLASS);
     $service_locator_stub = $this->createMock(ServiceLocatorInterface::CLASS);
     $service_locator_stub->method('createEntity')->willReturn($guard_stub);
     $workflows_file_path = __DIR__ . '/../../Fixture/BookSchema/Model/workflows.xml';
     $workflow_builder = new XmlStateMachineBuilder(['name' => self::AGGREGATE_ROOT_TYPE . '.default_workflow', 'state_machine_definition' => $workflows_file_path], $service_locator_stub);
     return $workflow_builder->build();
 }