3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\View\Helper
;
12 use Zend\View\Exception\InvalidArgumentException
;
13 use Zend\View\Helper\Placeholder\Container
;
16 * Helper for passing data between otherwise segregated Views. It's called
17 * Placeholder to make its typical usage obvious, but can be used just as easily
18 * for non-Placeholder things. That said, the support for this is only
19 * guaranteed to effect subsequently rendered templates, and of course Layouts.
21 class Placeholder
extends AbstractHelper
28 protected $items = array();
31 * Default container class
34 protected $containerClass = 'Zend\View\Helper\Placeholder\Container';
40 * @throws InvalidArgumentException
41 * @return Placeholder\Container\AbstractContainer
43 public function __invoke($name = null)
46 throw new InvalidArgumentException(
47 'Placeholder: missing argument. $name is required by placeholder($name)'
51 $name = (string) $name;
52 return $this->getContainer($name);
60 * @return Container\AbstractContainer
62 public function createContainer($key, array $value = array())
66 $this->items
[$key] = new $this->containerClass($value);
67 return $this->items
[$key];
71 * Retrieve a placeholder container
74 * @return Container\AbstractContainer
76 public function getContainer($key)
79 if (isset($this->items
[$key])) {
80 return $this->items
[$key];
83 $container = $this->createContainer($key);
89 * Does a particular container exist?
94 public function containerExists($key)
97 $return = array_key_exists($key, $this->items
);