|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
7 * This source file is subject to the new BSD license that is bundled |
|
8 * with this package in the file LICENSE.txt. |
|
9 * It is also available through the world-wide-web at this URL: |
|
10 * http://framework.zend.com/license/new-bsd |
|
11 * If you did not receive a copy of the license and are unable to |
|
12 * obtain it through the world-wide-web, please send an email |
|
13 * to license@zend.com so we can send you a copy immediately. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_View |
|
17 * @subpackage Helper |
|
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @version $Id: Placeholder.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
20 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
21 */ |
|
22 |
|
23 /** Zend_View_Helper_Placeholder_Registry */ |
|
24 require_once 'Zend/View/Helper/Placeholder/Registry.php'; |
|
25 |
|
26 /** Zend_View_Helper_Abstract.php */ |
|
27 require_once 'Zend/View/Helper/Abstract.php'; |
|
28 |
|
29 /** |
|
30 * Helper for passing data between otherwise segregated Views. It's called |
|
31 * Placeholder to make its typical usage obvious, but can be used just as easily |
|
32 * for non-Placeholder things. That said, the support for this is only |
|
33 * guaranteed to effect subsequently rendered templates, and of course Layouts. |
|
34 * |
|
35 * @package Zend_View |
|
36 * @subpackage Helper |
|
37 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
38 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
39 */ |
|
40 class Zend_View_Helper_Placeholder extends Zend_View_Helper_Abstract |
|
41 { |
|
42 /** |
|
43 * Placeholder items |
|
44 * @var array |
|
45 */ |
|
46 protected $_items = array(); |
|
47 |
|
48 /** |
|
49 * @var Zend_View_Helper_Placeholder_Registry |
|
50 */ |
|
51 protected $_registry; |
|
52 |
|
53 /** |
|
54 * Constructor |
|
55 * |
|
56 * Retrieve container registry from Zend_Registry, or create new one and register it. |
|
57 * |
|
58 * @return void |
|
59 */ |
|
60 public function __construct() |
|
61 { |
|
62 $this->_registry = Zend_View_Helper_Placeholder_Registry::getRegistry(); |
|
63 } |
|
64 |
|
65 |
|
66 /** |
|
67 * Placeholder helper |
|
68 * |
|
69 * @param string $name |
|
70 * @return Zend_View_Helper_Placeholder_Container_Abstract |
|
71 */ |
|
72 public function placeholder($name) |
|
73 { |
|
74 $name = (string) $name; |
|
75 return $this->_registry->getContainer($name); |
|
76 } |
|
77 |
|
78 /** |
|
79 * Retrieve the registry |
|
80 * |
|
81 * @return Zend_View_Helper_Placeholder_Registry |
|
82 */ |
|
83 public function getRegistry() |
|
84 { |
|
85 return $this->_registry; |
|
86 } |
|
87 } |