-
Notifications
You must be signed in to change notification settings - Fork 121
/
Copy pathtestinjectcustom.php
49 lines (36 loc) · 1005 Bytes
/
testinjectcustom.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
<?php
namespace App\Services {
class SimpleClass
{
private $varName;
public function __construct($varName)
{
$this->varName = $varName;
}
public function ping($pong)
{
return "[$this->varName] $pong";
}
}
}
namespace {
include "../lib/BladeOne.php";
use eftec\bladeone\BladeOne;
$views = __DIR__ . '/views';
$compiledFolder = __DIR__ . '/compiled';
$blade = new BladeOne($views, $compiledFolder, BladeOne::MODE_SLOW);
$blade->setInjectResolver(function ($className, $varName) {
$fullClassName = "App\\Services\\$className";
return new $fullClassName($varName);
});
$records = [1, 2, 3];
include "service/Metric.php";
try {
echo $blade->run("Test.inject2", ["name" => "hello"
, 'records' => $records
, 'emptyArray' => []
]);
} catch (Exception $e) {
echo $e->getMessage();
}
}