- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgraph.php
More file actions
Latest commit
37 lines (32 loc) · 1.02 KB
/
Copy pathgraph.php
File metadata and controls
37 lines (32 loc) · 1.02 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
<?php
require_once__DIR__.'/vendor/autoload.php';
useExample\Order\Process\Postpayment;
useExample\Order\Process\Prepayment;
useMetabor\NamedCollection;
useMetabor\Statemachine\Graph\GraphBuilder;
useFhaculty\Graph\Graph;
useGraphp\GraphViz\GraphViz;
try {
$processes = newNamedCollection();
$processes->add(newPrepayment());
$processes->add(newPostpayment());
if (isset($_GET['process'])) {
$processName = strtolower($_GET['process']);
if ($processes->has($processName)) {
$process = $processes->get($processName);
}
}
if (!isset($process)) {
$processNames = $processes->getNames();
$processName = reset($processNames);
$process = $processes->get($processName);
}
$graph = newGraph();
$builder = newGraphBuilder($graph);
$builder->addStateCollection($process);
$viz = newGraphViz();
$viz->setFormat('svg');
echofile_get_contents($viz->createImageFile($graph));
} catch (Exception$e) {
echo$e->getMessage();
}