-
Notifications
You must be signed in to change notification settings - Fork 243
Expand file tree
/
Copy pathStartEvent.php
More file actions
48 lines (39 loc) · 1.27 KB
/
StartEvent.php
File metadata and controls
48 lines (39 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace ProcessMaker\Jobs;
use ProcessMaker\Models\Process as Definitions;
use ProcessMaker\Nayra\Contracts\Bpmn\ProcessInterface;
use ProcessMaker\Nayra\Contracts\Bpmn\StartEventInterface;
class StartEvent extends BpmnAction
{
public $definitionsId;
public $processId;
public $elementId;
public $data;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(Definitions $definitions, StartEventInterface $event, array $data)
{
$this->definitionsId = $definitions->getKey();
$this->processId = $event->getOwnerProcess()->getId();
$this->elementId = $event->getId();
$this->data = $data;
}
/**
* Start a $process from start event $element.
*
* @return \ProcessMaker\Nayra\Contracts\Engine\ExecutionInstanceInterface
*/
public function action(ProcessInterface $process, StartEventInterface $element)
{
//Create a new data store
$dataStorage = $process->getRepository()->createDataStore();
$dataStorage->setData($this->data);
$instance = $process->getEngine()->createExecutionInstance($process, $dataStorage);
$element->start($instance);
//Return the instance created
return $instance;
}
}