/** * Renders the TypoScript object in the given TypoScript setup path. * * @param string $typoscriptObjectPath the TypoScript setup path of the TypoScript object to render * @param mixed $data the data to be used for rendering the cObject. Can be an object, array or string. If this argument is not set, child nodes will be used * @param string $currentValueKey * @return string the content of the rendered TypoScript object * @author Bastian Waidelich <*****@*****.**> * @author Niels Pardon <*****@*****.**> */ public function render($typoscriptObjectPath, $data = NULL, $currentValueKey = NULL) { if ($data === NULL) { $data = $this->renderChildren(); } $currentValue = NULL; if (is_object($data)) { $data = Tx_Extbase_Reflection_ObjectAccess::getAccessibleProperties($data); } elseif (is_string($data)) { $currentValue = $data; $data = array($data); } $this->contentObject->start($data); if ($currentValue !== NULL) { $this->contentObject->setCurrentVal($currentValue); } elseif ($currentValueKey !== NULL && isset($data[$currentValueKey])) { $this->contentObject->setCurrentVal($data[$currentValueKey]); } $pathSegments = t3lib_div::trimExplode('.', $typoscriptObjectPath); $lastSegment = array_pop($pathSegments); $setup = $this->typoScriptSetup; foreach ($pathSegments as $segment) { if (!array_key_exists($segment . '.', $setup)) { throw new Tx_Fluid_Core_ViewHelper_Exception('TypoScript object path "' . htmlspecialchars($typoscriptObjectPath) . '" does not exist', 1253191023); } $setup = $setup[$segment . '.']; } return $this->contentObject->cObjGetSingle($setup[$lastSegment], $setup[$lastSegment . '.']); }