FluidTYPO3\Flux\Service\FluxService::convertFlexFormContentToArray PHP Method

convertFlexFormContentToArray() public method

Note: multi-language flexForms are not supported yet
public convertFlexFormContentToArray ( string $flexFormContent, Form $form = NULL, string $languagePointer = 'lDEF', string $valuePointer = 'vDEF' ) : array
$flexFormContent string flexForm xml string
$form FluidTYPO3\Flux\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
    public function convertFlexFormContentToArray($flexFormContent, Form $form = NULL, $languagePointer = 'lDEF', $valuePointer = 'vDEF')
    {
        if (TRUE === empty($flexFormContent)) {
            return array();
        }
        $formTranslationDisabled = NULL !== $form && FALSE === (bool) $form->getOption(Form::OPTION_TRANSLATION);
        if (TRUE === empty($languagePointer) || TRUE === $formTranslationDisabled) {
            $languagePointer = 'lDEF';
        }
        if (TRUE === empty($valuePointer) || TRUE === $formTranslationDisabled) {
            $valuePointer = 'vDEF';
        }
        $settings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Service\\FlexFormService')->convertFlexFormContentToArray($flexFormContent, $languagePointer, $valuePointer);
        if (NULL !== $form) {
            /** @var FormDataTransformer $transformer */
            $transformer = $this->objectManager->get('FluidTYPO3\\Flux\\Transformation\\FormDataTransformer');
            $settings = $transformer->transformAccordingToConfiguration($settings, $form);
        }
        return $settings;
    }

Usage Example

 /**
  * 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;
 }
All Usage Examples Of FluidTYPO3\Flux\Service\FluxService::convertFlexFormContentToArray