Note: multi-language flexForms are not supported yet
public convertFlexFormContentToArray ( string $flexFormContent, |
||
$flexFormContent | string | flexForm xml string |
$form | An instance of \FluidTYPO3\Flux\Form. If transformation instructions are contained in this configuration they are applied after conversion to array | |
$languagePointer | string | language pointer used in the flexForm |
$valuePointer | string | value pointer used in the flexForm |
return | array | the processed array |
/** * 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; }
/** * @param array $providers * @param array $record * @param string $field * @return array */ protected function readDataArrayFromProvidersOrUsingDefaultMethod(array $providers, $record, $field) { 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); } } return $dataArray; }
/** * @param array $providers * @param array $record * @param string $field * @return array */ protected static function readDataArrayFromProvidersOrUsingDefaultMethod(array $providers, $record, $field) { if (0 === count($providers)) { $lang = static::getCurrentLanguageName(); $pointer = static::getCurrentValuePointerName(); $dataArray = static::$configurationService->convertFlexFormContentToArray($record[$field], NULL, $lang, $pointer); } else { $dataArray = array(); /** @var ProviderInterface $provider */ foreach ($providers as $provider) { $data = (array) $provider->getFlexFormValues($record); $dataArray = RecursiveArrayUtility::merge($dataArray, $data); } } return $dataArray; }
/** * Converts the contents of the provided row's Flux-enabled field, * at the same time running through the inheritance tree generated * by getInheritanceTree() in order to apply inherited values. * * @param array $row * @return array */ public function getFlexFormValues(array $row) { $fieldName = $this->getFieldName($row); $form = $this->getForm($row); $languageName = $this->getCurrentLanguageName(); $valuePointer = $this->getCurrentValuePointerName(); return $this->configurationService->convertFlexFormContentToArray($row[$fieldName], $form, $languageName, $valuePointer); }
/** * Converts the contents of the provided row's Flux-enabled field, * at the same time running through the inheritance tree generated * by getInheritanceTree() in order to apply inherited values. * * @param array $row * @return array */ public function getFlexFormValues(array $row) { $fieldName = $this->getFieldName($row); $cacheKey = 'values_' . md5(json_encode($row) . $fieldName); if (TRUE === isset(self::$cache[$cacheKey])) { return self::$cache[$cacheKey]; } $form = $this->getForm($row); $immediateConfiguration = $this->configurationService->convertFlexFormContentToArray($row[$fieldName], $form, NULL, NULL); $tree = $this->getInheritanceTree($row); if (0 === count($tree)) { self::$cache[$cacheKey] = $immediateConfiguration; return (array) $immediateConfiguration; } $inheritedConfiguration = $this->getMergedConfiguration($tree); if (0 === count($immediateConfiguration)) { self::$cache[$cacheKey] = $inheritedConfiguration; return (array) $inheritedConfiguration; } $merged = RecursiveArrayUtility::merge($inheritedConfiguration, $immediateConfiguration); self::$cache[$cacheKey] = $merged; return $merged; }