1: <?php
2: /**
3: * Copyright 2007-2008 Maintainable Software, LLC
4: * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
5: *
6: * @author Mike Naberezny <mike@maintainable.com>
7: * @author Derek DeVries <derek@maintainable.com>
8: * @author Chuck Hagenbuch <chuck@horde.org>
9: * @license http://www.horde.org/licenses/bsd
10: * @category Horde
11: * @package View
12: * @subpackage Helper
13: */
14:
15: /**
16: * An instance of this class is returned by
17: * Horde_View_Helper_Capture::contentFor().
18: *
19: * @author Mike Naberezny <mike@maintainable.com>
20: * @author Derek DeVries <derek@maintainable.com>
21: * @author Chuck Hagenbuch <chuck@horde.org>
22: * @license http://www.horde.org/licenses/bsd
23: * @category Horde
24: * @package View
25: * @subpackage Helper
26: */
27: class Horde_View_Helper_Capture_ContentFor extends Horde_View_Helper_Capture_Base
28: {
29: /**
30: * Name that will become "$this->contentForName".
31: *
32: * @var string
33: */
34: private $_name;
35:
36: /**
37: * Starts capturing content that will be stored as $view->contentForName.
38: *
39: * @param string $name Name of the content that becomes the
40: * instance variable name.
41: * "foo" -> "$this->contentForFoo"
42: * @param Horde_View_Base $view A view object.
43: */
44: public function __construct($name, $view)
45: {
46: $this->_name = $name;
47: $this->_view = $view;
48: parent::__construct();
49: }
50:
51: /**
52: * Stops capturing content and stores it in the view.
53: */
54: public function end()
55: {
56: $name = 'contentFor' . Horde_String::ucfirst($this->_name);
57: $this->_view->$name = parent::end();
58: }
59: }
60: