Placeholder.php 2.4 KB

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