forked from ProcessMaker/processmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcessObserver.php
More file actions
51 lines (46 loc) · 1.41 KB
/
ProcessObserver.php
File metadata and controls
51 lines (46 loc) · 1.41 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
49
50
51
<?php
namespace ProcessMaker\Observers;
use ProcessMaker\Exception\ReferentialIntegrityException;
use ProcessMaker\Models\Process;
use ProcessMaker\Models\ProcessRequest;
use ProcessMaker\Package\WebEntry\Models\WebentryRoute;
class ProcessObserver
{
/**
* Handle the Process "deleting" event.
*
* @param Process $process
* @throws ReferentialIntegrityException
*/
public function deleting(Process $process)
{
//A process can not be deleted if it has requests
$query = ProcessRequest::where('process_id', $process->id);
$count = $query->count();
if ($count > 0) {
throw new ReferentialIntegrityException($process, $query->first());
}
}
/**
* Handle the Process "saving" event.
*
* @param Process $process
*/
public function saving(Process $process)
{
$process->start_events = $process->getUpdatedStartEvents();
$process->self_service_tasks = $process->getUpdatedSelfServiceTasks();
$process->signal_events = $process->getUpdatedStartEventsSignalEvents();
$process->conditional_events = $process->getUpdatedConditionalStartEvents();
$process->validateBpmnDefinition(true);
}
/**
* Handle the Process "saved" event.
*
* @param Process $process
*/
public function saved(Process $process)
{
$process->manageCustomRoutes();
}
}