1: <?php
2: /**
3: * @category Horde
4: * @package View
5: * @subpackage Helper
6: */
7:
8: /**
9: * Abstract class for Horde_View_Helper objects.
10: *
11: * All helpers hold a link back to the instance of the view. The undefined
12: * property handlers (__get()/__call() methods) are used to mix helpers
13: * together, effectively placing them on the same pane of glass (the view) and
14: * allowing any helper to call any other.
15: *
16: * @category Horde
17: * @package View
18: * @subpackage Helper
19: */
20: abstract class Horde_View_Helper_Base
21: {
22: /**
23: * The parent view invoking the helper.
24: *
25: * @var Horde_View
26: */
27: protected $_view;
28:
29: /**
30: * Creates a helper for $view.
31: *
32: * @param Horde_View $view The view to help.
33: */
34: public function __construct($view)
35: {
36: $this->_view = $view;
37: $view->addHelper($this);
38: }
39:
40: /**
41: * Proxy on undefined property access (get).
42: */
43: public function __get($name)
44: {
45: return $this->_view->$name;
46: }
47:
48: /**
49: * Proxy on undefined property access (set).
50: */
51: public function __set($name, $value)
52: {
53: return $this->_view->$name = $value;
54: }
55:
56: /**
57: * Call chaining so members of the view can be called (including other
58: * helpers).
59: *
60: * @param string $method The method.
61: * @param array $args The parameters for the method.
62: *
63: * @return mixed The result of the method.
64: */
65: public function __call($method, $args)
66: {
67: return call_user_func_array(array($this->_view, $method), $args);
68: }
69: }
70: