2
0

Placeholder.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. * @package Zend_View
  16. * @subpackage Helper
  17. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @version $Id$
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /** Zend_View_Helper_Placeholder_Registry */
  22. require_once 'Zend/View/Helper/Placeholder/Registry.php';
  23. /** Zend_View_Helper_Abstract.php */
  24. require_once 'Zend/View/Helper/Abstract.php';
  25. /**
  26. * Helper for passing data between otherwise segregated Views. It's called
  27. * Placeholder to make its typical usage obvious, but can be used just as easily
  28. * for non-Placeholder things. That said, the support for this is only
  29. * guaranteed to effect subsequently rendered templates, and of course Layouts.
  30. *
  31. * @package Zend_View
  32. * @subpackage Helper
  33. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. */
  36. class Zend_View_Helper_Placeholder extends Zend_View_Helper_Abstract
  37. {
  38. /**
  39. * Placeholder items
  40. * @var array
  41. */
  42. protected $_items = array();
  43. /**
  44. * @var Zend_View_Helper_Placeholder_Registry
  45. */
  46. protected $_registry;
  47. /**
  48. * Constructor
  49. *
  50. * Retrieve container registry from Zend_Registry, or create new one and register it.
  51. *
  52. * @return void
  53. */
  54. public function __construct()
  55. {
  56. $this->_registry = Zend_View_Helper_Placeholder_Registry::getRegistry();
  57. }
  58. /**
  59. * Placeholder helper
  60. *
  61. * @param string $name
  62. * @return Zend_View_Helper_Placeholder_Container_Abstract
  63. */
  64. public function placeholder($name)
  65. {
  66. $name = (string) $name;
  67. return $this->_registry->getContainer($name);
  68. }
  69. /**
  70. * Retrieve the registry
  71. *
  72. * @return Zend_View_Helper_Placeholder_Registry
  73. */
  74. public function getRegistry()
  75. {
  76. return $this->_registry;
  77. }
  78. }