-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
53 lines (42 loc) · 1.67 KB
/
index.php
File metadata and controls
53 lines (42 loc) · 1.67 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
52
53
<?php
$loader = require __DIR__ . '/vendor/autoload.php';
use ManagerNode\BinaryNode;
use ManagerNode\Node;
// Creating Nodes
$root = new Node(10, 'form.identity');
$patrimony = new Node(20, 'form.patrimony');
$experience = new Node(30, 'form.experience');
$target = new Node(40, 'form.target');
$choice = new Node(50, 'form.identity_proof.choice');
$passeport = new Node(51, 'form.identity_proof.passeport'); // These two steps have equal priority, we'll let the user decide which one he want
$rectoId = new Node(51, 'form.identity_proof.identity-recto'); // These two steps have equal priority, we'll let the user decide which one he want
$versoId = new Node(52, 'form.identity_proof.identity-verso');
$domicile = new Node(60, 'form.justification.dom');
$signature = new BinaryNode(70, 'form.signature', 'form.error');
// Assembling nodes
$root->addChildren($patrimony);
$patrimony->addChildren($experience);
$experience->addChildren($target);
$target->addChildren($choice);
$choice->addChildren($passeport);
$choice->addChildren($rectoId);
$rectoId->addChildren($versoId);
$versoId->addChildren($domicile);
$passeport->addChildren($domicile);
$domicile->addChildren($signature);
// Mock the symfony validator
$root->setValidity(true);
$patrimony->setValidity(true);
$experience->setValidity(true);
$target->setValidity(true);
$choice->setValidity(true);
$passeport->setValidity(false);
$rectoId->setValidity(true);
$versoId->setValidity(true);
$domicile->setValidity(true);
$signature->setValidity(true);
// Go !
$best = $root->tryAccess($signature->prioritize());
// Want to validate only uplodad parts? Easy !
// $best = $choice->tryAccess($signature->prioritize());
var_dump($best->getName());