| 1: | <?php
|
| 2: |
|
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: |
|
| 12: | class Smarty_Internal_Method_RegisterObject
|
| 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: | |
| 39: | |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | |
| 50: | |
| 51: | |
| 52: | |
| 53: |
|
| 54: | public function registerObject(
|
| 55: | Smarty_Internal_TemplateBase $obj,
|
| 56: | $object_name,
|
| 57: | $object,
|
| 58: | $allowed_methods_properties = array(),
|
| 59: | $format = true,
|
| 60: | $block_methods = array()
|
| 61: | ) {
|
| 62: | $smarty = $obj->_getSmartyObj();
|
| 63: |
|
| 64: | if (!empty($allowed_methods_properties)) {
|
| 65: | foreach ((array)$allowed_methods_properties as $method) {
|
| 66: | if (!is_callable(array($object, $method)) && !property_exists($object, $method)) {
|
| 67: | throw new SmartyException("Undefined method or property '$method' in registered object");
|
| 68: | }
|
| 69: | }
|
| 70: | }
|
| 71: |
|
| 72: | if (!empty($block_methods)) {
|
| 73: | foreach ((array)$block_methods as $method) {
|
| 74: | if (!is_callable(array($object, $method))) {
|
| 75: | throw new SmartyException("Undefined method '$method' in registered object");
|
| 76: | }
|
| 77: | }
|
| 78: | }
|
| 79: |
|
| 80: | $smarty->registered_objects[ $object_name ] =
|
| 81: | array($object, (array)$allowed_methods_properties, (boolean)$format, (array)$block_methods);
|
| 82: | return $obj;
|
| 83: | }
|
| 84: | }
|
| 85: | |