1: | <?php
|
2: |
|
3: | |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: |
|
12: | class Smarty_Internal_Method_RegisterPlugin
|
13: | {
|
14: | |
15: | |
16: | |
17: | |
18: |
|
19: | public $objMap = 3;
|
20: |
|
21: | |
22: | |
23: | |
24: | |
25: | |
26: | |
27: | |
28: | |
29: | |
30: | |
31: | |
32: | |
33: | |
34: | |
35: | |
36: | |
37: |
|
38: | public function registerPlugin(
|
39: | Smarty_Internal_TemplateBase $obj,
|
40: | $type,
|
41: | $name,
|
42: | $callback,
|
43: | $cacheable = true,
|
44: | $cache_attr = null
|
45: | ) {
|
46: | $smarty = $obj->_getSmartyObj();
|
47: | if (isset($smarty->registered_plugins[ $type ][ $name ])) {
|
48: | throw new SmartyException("Plugin tag '{$name}' already registered");
|
49: | } elseif (!is_callable($callback)) {
|
50: | throw new SmartyException("Plugin '{$name}' not callable");
|
51: | } elseif ($cacheable && $cache_attr) {
|
52: | throw new SmartyException("Cannot set caching attributes for plugin '{$name}' when it is cacheable.");
|
53: | } else {
|
54: | $smarty->registered_plugins[ $type ][ $name ] = array($callback, (bool)$cacheable, (array)$cache_attr);
|
55: | }
|
56: | return $obj;
|
57: | }
|
58: | }
|
59: | |