Хранилища Subversion ant

Редакция

К новейшей редакции | Содержимое файла | Последнее изменение | Открыть журнал | RSS

Редакция Автор № строки Строка
304 alex-w 1
<?php
2
 
3
/**
4
* Smarty method Register_Object
5
*
6
* Registers a PHP object
7
*
8
* @package Smarty
9
* @subpackage SmartyMethod
10
* @author Uwe Tews
11
*/
12
 
13
/**
14
* Registers object to be used in templates
15
*
16
* @param object $smarty
17
* @param string $object name of template object
18
* @param object $ &$object_impl the referenced PHP object to register
19
* @param null $ |array $allowed list of allowed methods (empty = all)
20
* @param boolean $smarty_args smarty argument format, else traditional
21
* @param null $ |array $block_functs list of methods that are block format
22
*/
23
function register_object($smarty, $object, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
24
{
25
    // test if allowed methodes callable
26
    if (!empty($allowed)) {
27
        foreach ((array)$allowed as $methode) {
28
            if (!is_callable(array($object_impl, $methode))) {
29
                throw new Exception("Undefined methode '$methode' in registered object");
30
            }
31
        }
32
    }
33
    // test if block methodes callable
34
    if (!empty($block_methods)) {
35
        foreach ((array)$block_methods as $methode) {
36
            if (!is_callable(array($object_impl, $methode))) {
37
                throw new Exception("Undefined methode '$methode' in registered object");
38
            }
39
        }
40
    }
41
    // register the object
42
    $smarty->registered_objects[$object] =
43
    array($object_impl, (array)$allowed, (boolean)$smarty_args, (array)$block_methods);
44
}
45
 
46
?>