-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexamplevariable2.php
50 lines (43 loc) · 1.17 KB
/
examplevariable2.php
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
<?php
use eftec\minilang\MiniLang;
include "../lib/MiniLang.php";
class MyModel {
var $id=1;
var $value="";
public function __construct($id=0, $value="")
{
$this->id = $id;
$this->value = $value;
}
public function callMe($arg="",$arg2="",$arg3="") {
echo "calling callMe()";
var_dump($arg);
var_dump($arg2);
var_dump($arg3);
}
}
class ClassCaller {
public function Processcaller($arg) {
echo "Caller: setting the variable {$arg->id}<br>";
}
}
class ClassService {
public function ProcessService($arg) {
echo "Service: setting the variable {$arg->id}<br>";
}
}
$variables=['field1'=>new MyModel(1,"hi")
,'field2'=>new MyModel(2,'')
,'field3'=>new MyModel(3,'')]; // we define regular variables
$callback=new ClassCaller();
$mini=new MiniLang($callback,$variables,[],[],new ClassService());
$mini->separate("when field1.id>0 then
field2.value=3
and field2.callme(20,1,2)
and field3.processcaller
and processcaller(field3)
and processservice(field3)"); // we prepare the language
$mini->evalAllLogic(false); // we set the variables and run the languageand run the language
echo "<pre>";
var_dump($variables);
echo "</pre>";