Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / View / Helper / Layout.php
blob5b4dc47e352689e5d5d4b0d8485cda9564e5cbbd
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\View\Helper;
12 use Zend\View\Exception;
13 use Zend\View\Model\ModelInterface as Model;
15 /**
16 * View helper for retrieving layout object
18 class Layout extends AbstractHelper
20 /**
21 * @var ViewModel
23 protected $viewModelHelper;
25 /**
26 * Set layout template or retrieve "layout" view model
28 * If no arguments are given, grabs the "root" or "layout" view model.
29 * Otherwise, attempts to set the template for that view model.
31 * @param null|string $template
32 * @return Layout
34 public function __invoke($template = null)
36 if (null === $template) {
37 return $this->getRoot();
40 return $this->setTemplate($template);
43 /**
44 * Get layout template
46 * @return string
48 public function getLayout()
50 return $this->getRoot()->getTemplate();
53 /**
54 * Get the root view model
56 * @throws Exception\RuntimeException
57 * @return null|Model
59 protected function getRoot()
61 $helper = $this->getViewModelHelper();
63 if (!$helper->hasRoot()) {
64 throw new Exception\RuntimeException(sprintf(
65 '%s: no view model currently registered as root in renderer',
66 __METHOD__
67 ));
70 return $helper->getRoot();
73 /**
74 * Set layout template
76 * @param string $template
77 * @return Layout
79 public function setTemplate($template)
81 $this->getRoot()->setTemplate((string) $template);
82 return $this;
85 /**
86 * Retrieve the view model helper
88 * @return ViewModel
90 protected function getViewModelHelper()
92 if (null === $this->viewModelHelper) {
93 $this->viewModelHelper = $this->getView()->plugin('view_model');
96 return $this->viewModelHelper;