getView()->render($name); } if (is_scalar($values)) { $values = []; } elseif ($values instanceof ModelInterface) { $values = $values->getVariables(); } elseif (is_object($values)) { if (null !== ($objectKey = $this->getObjectKey())) { $values = [$objectKey => $values]; } elseif (method_exists($values, 'toArray')) { $values = $values->toArray(); } else { $values = get_object_vars($values); } } return $this->getView()->render($name, $values); } /** * Set object key * * @param string|null $key * * @return self */ public function setObjectKey($key) { if (null === $key) { $this->objectKey = null; return $this; } $this->objectKey = (string) $key; return $this; } /** * Retrieve object key * * The objectKey is the variable to which an object in the iterator will be * assigned. * * @return null|string */ public function getObjectKey() { return $this->objectKey; } }