-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathFn.php
More file actions
63 lines (51 loc) · 1.84 KB
/
Fn.php
File metadata and controls
63 lines (51 loc) · 1.84 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
54
55
56
57
58
59
60
61
62
63
<?php
class Evil_Fn
{
protected static $_drivers = array();
protected static $_functions = array();
protected static $_domain;
public static function onInclude()
{
$config = Zend_Registry::get('config');
if (isset($config['evil']['fn']))
self::$_drivers = $config['evil']['fn'];
}
public static function Fn($fn, $code = null)
{
self::$_functions[self::$_domain][$fn] = $code;
}
public static function run($call)
{
$pieces = explode('.', $call['NS']);
list($group) = array_reverse($pieces);
$path = strtr($call['NS'],'.','/');
if (isset($call['D']))
$driver = $call['D'];
else
{
$driver = $group;
if (isset(self::$_drivers[$pieces[0]]))
{
$iter = self::$_drivers[$pieces[0]];
$sz = sizeof($pieces);
for($ic = 1; $ic<$sz; $ic++)
if (isset($iter[$pieces[$ic]]))
$iter = $iter[$pieces[$ic]];
else
$iter = null;
if (null !== $iter)
$driver = $iter;
}
}
self::$_domain = $path;
$driverPath = Evil_Locator::ff('/functions/'.$path.'/'.$driver.'.php');
if (!empty($driverPath))
{
include_once $driverPath;
$closure = self::$_functions[self::$_domain][$call['F']];
return $closure ($call);
}
else throw new Exception('driver '.'/functions/'.$path.'/'.$driver.'.php'.' not found');
}
}
Evil_Fn::onInclude();