fix calendar css, take 2. (#213)
[openemr.git] / interface / modules / zend_modules / library / Zend / View / Helper / Partial.php
blob68ffe677c967a90cb5ee8e37747a10a0e2e3498a
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-2015 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;
15 /**
16 * Helper for rendering a template fragment in its own variable scope.
18 class Partial extends AbstractHelper
20 /**
21 * Variable to which object will be assigned
23 * @var string
25 protected $objectKey;
27 /**
28 * Renders a template fragment within a variable scope distinct from the
29 * calling View object. It proxies to view's render function
31 * @param string|ModelInterface $name Name of view script, or a view model
32 * @param array|object $values Variables to populate in the view
33 * @throws Exception\RuntimeException
34 * @return string|Partial
36 public function __invoke($name = null, $values = null)
38 if (0 == func_num_args()) {
39 return $this;
42 // If we were passed only a view model, just render it.
43 if ($name instanceof ModelInterface) {
44 return $this->getView()->render($name);
47 if (is_scalar($values)) {
48 $values = array();
49 } elseif ($values instanceof ModelInterface) {
50 $values = $values->getVariables();
51 } elseif (is_object($values)) {
52 if (null !== ($objectKey = $this->getObjectKey())) {
53 $values = array($objectKey => $values);
54 } elseif (method_exists($values, 'toArray')) {
55 $values = $values->toArray();
56 } else {
57 $values = get_object_vars($values);
61 return $this->getView()->render($name, $values);
64 /**
65 * Set object key
67 * @param string|null $key
69 * @return self
71 public function setObjectKey($key)
73 if (null === $key) {
74 $this->objectKey = null;
75 return $this;
78 $this->objectKey = (string) $key;
80 return $this;
83 /**
84 * Retrieve object key
86 * The objectKey is the variable to which an object in the iterator will be
87 * assigned.
89 * @return null|string
91 public function getObjectKey()
93 return $this->objectKey;