/**
* Render method
* @param string $table
* @param string $field
* @param integer $uid
* @param array $record
* @param string $as
* @return array
* @throws Exception
*/
public function render($table, $field, $uid = NULL, $record = NULL, $as = NULL)
{
if (NULL === $uid && NULL !== $record && TRUE === isset($record['uid'])) {
$uid = $record['uid'];
}
if (TRUE === isset(self::$dataCache[$uid . $table . $field])) {
$dataArray = self::$dataCache[$uid . $table . $field];
} elseif (TRUE === isset($GLOBALS['TCA'][$table]) && TRUE === isset($GLOBALS['TCA'][$table]['columns'][$field])) {
if (NULL === $record) {
$record = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('uid,' . $field, $table, sprintf('uid=%d', $uid));
}
if (FALSE === $record) {
throw new Exception(sprintf('Either table "%s", field "%s" or record with uid %d do not exist and you did not manually ' . 'provide the "row" attribute.', $table, $field, $uid), 1358679983);
}
$providers = $this->configurationService->resolveConfigurationProviders($table, $field, $record);
if (0 === count($providers)) {
$dataArray = $this->configurationService->convertFlexFormContentToArray($record[$field]);
} else {
$dataArray = array();
foreach ($providers as $provider) {
$data = (array) $provider->getFlexFormValues($record);
$dataArray = RecursiveArrayUtility::merge($dataArray, $data);
}
}
self::$dataCache[$uid . $table . $field] = $dataArray;
} else {
throw new Exception('Invalid table:field "' . $table . ':' . $field . '" - does not exist in TYPO3 TCA.', 1387049117);
}
if (NULL !== $as) {
if ($this->templateVariableContainer->exists($as)) {
$backupVariable = $this->templateVariableContainer->get($as);
$this->templateVariableContainer->remove($as);
}
$this->templateVariableContainer->add($as, $dataArray);
$content = $this->renderChildren();
$this->templateVariableContainer->remove($as);
if (TRUE === isset($backupVariable)) {
$this->templateVariableContainer->add($as, $backupVariable);
}
return $content;
}
return $dataArray;
}