Beispiel #1
0
 /**
  * Reformat array for createAction
  *
  * @return void
  */
 protected function reformatParamsForAction()
 {
     $arguments = $this->request->getArguments();
     if (!isset($arguments['field'])) {
         return;
     }
     $newArguments = array('mail' => $arguments['mail']);
     // allow subvalues in new property mapper
     $mailMvcArgument = $this->arguments->getArgument('mail');
     $propertyMappingConfiguration = $mailMvcArgument->getPropertyMappingConfiguration();
     $propertyMappingConfiguration->allowProperties('answers');
     $propertyMappingConfiguration->allowCreationForSubProperty('answers');
     $propertyMappingConfiguration->allowModificationForSubProperty('answers');
     $propertyMappingConfiguration->allowProperties('form');
     $propertyMappingConfiguration->allowCreationForSubProperty('form');
     $propertyMappingConfiguration->allowModificationForSubProperty('form');
     // allow creation of new objects (for validation)
     $propertyMappingConfiguration->setTypeConverterOptions('TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\PersistentObjectConverter', array(PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED => TRUE, PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED => TRUE));
     $i = 0;
     foreach ((array) $arguments['field'] as $marker => $value) {
         // ignore internal fields (honeypod)
         if (substr($marker, 0, 2) === '__') {
             continue;
         }
         $fieldUid = $this->div->getFieldUidFromMarker($marker, $arguments['mail']['form']);
         // Skip fields without Uid (secondary password, upload)
         if ($fieldUid === 0) {
             continue;
         }
         // allow subvalues in new property mapper
         $propertyMappingConfiguration->forProperty('answers')->allowProperties($i);
         $propertyMappingConfiguration->forProperty('answers.' . $i)->allowAllProperties();
         $propertyMappingConfiguration->allowCreationForSubProperty('answers.' . $i);
         $propertyMappingConfiguration->allowModificationForSubProperty('answers.' . $i);
         $valueType = Div::getDataTypeFromFieldType($this->div->getFieldTypeFromMarker($marker, $arguments['mail']['form']));
         if ($valueType === 3 && is_array($value)) {
             $value = BasicFileFunctions::getUniqueNamesForFileUploads($value, $this->settings, FALSE);
         }
         if (is_array($value)) {
             if (empty($value)) {
                 $value = '';
             } else {
                 $value = json_encode($value);
             }
         }
         $newArguments['mail']['answers'][$i] = array('field' => strval($fieldUid), 'value' => $value, 'valueType' => $valueType);
         // edit form: add answer id
         if (!empty($arguments['field']['__identity'])) {
             $newArguments['mail']['answers'][$i]['__identity'] = $this->answerRepository->findByFieldAndMail($fieldUid, $arguments['field']['__identity'])->getUid();
         }
         $i++;
     }
     // edit form: add mail id
     if (!empty($arguments['field']['__identity'])) {
         $newArguments['mail']['__identity'] = $arguments['field']['__identity'];
     }
     $this->request->setArguments($newArguments);
     $this->request->setArgument('field', NULL);
 }