/** * @return WorkflowId */ public function workflowId() { if (is_null($this->workflowId)) { $this->workflowId = WorkflowId::fromString($this->aggregateId()); } return $this->workflowId; }
/** * @test */ function it_set_up_a_new_workflow() { $node = ProcessingNode::initializeAs(NodeName::defaultName()); $workflowId = WorkflowId::generate(); $workflow = $node->setUpNewWorkflow($workflowId, 'Article Export'); $this->assertTrue(NodeName::defaultName()->equals($workflow->processingNodeName())); $this->assertTrue($workflowId->equals($workflow->workflowId())); $this->assertEquals('Article Export', $workflow->name()); }
/** * @param mixed $data * @return mixed|void */ public function create($data) { if (!array_key_exists('name', $data)) { return $this->apiProblem(422, "No name given for the workflow"); } $workflowId = WorkflowId::generate(); try { $command = CreateWorkflow::withName($data['name'], $workflowId); } catch (\Exception $e) { return $this->apiProblem(422, $e->getMessage()); } $this->commandBus->dispatch($command); return $this->location($this->url()->fromRoute('prooph.link/process_config/api/workflow', ['id' => $workflowId->toString()])); }
/** * @test * @dataProvider provideStartScenarios */ function it_determines_one_start_task_managed_by_one_process_as_long_as_message_handler_is_located_on_the_same_processing_node(Workflow\Message $startMessage, MessageHandler $firstMessageHandler, ProcessingMetadata $taskMetadata, $expectedTaskType, $expectedProcessType) { $workflow = Workflow::locatedOn(NodeName::defaultName(), WorkflowId::generate(), 'Article Export'); //Pop the WorkflowWasCreatedEvent $this->extractRecordedEvents($workflow); $tasks = $workflow->determineFirstTasks($startMessage, $firstMessageHandler, $taskMetadata); $this->assertEquals(1, count($tasks)); $this->assertInstanceOf(Task::class, $tasks[0]); $this->assertEquals($expectedTaskType, $tasks[0]->type()->toString()); $this->assertTrue($firstMessageHandler->messageHandlerId()->equals($tasks[0]->messageHandlerId())); $domainEvents = $this->extractRecordedEvents($workflow); $this->assertEquals(3, count($domainEvents)); $this->assertInstanceOf(Workflow\StartMessageWasAssignedToWorkflow::class, $domainEvents[0]); $this->assertInstanceOf(Workflow\ProcessWasAddedToWorkflow::class, $domainEvents[1]); $this->assertInstanceOf(Workflow\TaskWasAddedToProcess::class, $domainEvents[2]); foreach ($domainEvents as $domainEvent) { if ($domainEvent instanceof Workflow\ProcessWasAddedToWorkflow) { $this->assertEquals($expectedProcessType, $domainEvent->processType()->toString()); } } }
/** * @return WorkflowId */ public function workflowId() { return WorkflowId::fromString($this->payload['workflow_id']); }
/** * @return string representation of the unique identifier of the aggregate root */ protected function aggregateId() { return $this->workflowId->toString(); }
/** * @return WorkflowId */ public function workflowId() { return WorkflowId::fromString($this->aggregateId()); }
/** * @param WorkflowId $other * @return bool */ public function equals(WorkflowId $other) { return $this->toString() === $other->toString(); }
/** * @param WorkflowId $workflowId * @return WorkflowNotFound */ public static function withId(WorkflowId $workflowId) { return new self(sprintf('Workflow with id %s could not be found', $workflowId->toString())); }
/** * @param WorkflowId $workflowId * @return Workflow */ public function get(WorkflowId $workflowId) { return $this->getAggregateRoot($workflowId->toString()); }