Exemplo n.º 1
0
 /**
  * Creates an entity as an array that you can submit as if you used a form
  * 
  * @param  string $argumentName                the name
  * @param  Object $persistedEntity             the Entity that you'd like to create this argument from
  * @param  array  $customProperties            the properties to set if wished
  * @param  array  $additionalTrustedProperties more properties to be trusted
  * @return array  the argument you can then submit
  */
 public function getSubmitArgumentsForPersistedEntity($argumentName, $persistedEntity, $customProperties = array(), $additionalTrustedProperties = array())
 {
     $arguments = array($argumentName => $this->getIdentityArgumentFromPersistedEntity($persistedEntity));
     $propertyNamesForMappingService = array($argumentName . '[__identity]') + $additionalTrustedProperties;
     // set the properties
     foreach ($customProperties as $propertyName => $propertyValue) {
         $arguments[$argumentName][$propertyName] = $propertyValue;
         $propertyNamesForMappingService[] = $argumentName . '[' . $propertyName . ']';
     }
     $propertyNamesForMappingService[] = '';
     // add __trustedProperties
     $arguments['__trustedProperties'] = $this->mvcPropertyMappingConfigurationService->generateTrustedPropertiesToken($propertyNamesForMappingService, '');
     // add __csrfToken
     $arguments['__csrfToken'] = $this->securityContext->getCsrfProtectionToken();
     return $arguments;
 }
 /**
  * Render the request hash field
  *
  * @return string the hmac field
  */
 protected function renderTrustedPropertiesField()
 {
     $formFieldNames = $this->viewHelperVariableContainer->get('TYPO3\\Fluid\\ViewHelpers\\FormViewHelper', 'formFieldNames');
     $requestHash = $this->mvcPropertyMappingConfigurationService->generateTrustedPropertiesToken($formFieldNames, $this->getFieldNamePrefix());
     return '<input type="hidden" name="' . $this->prefixFieldName('__trustedProperties') . '" value="' . htmlspecialchars($requestHash) . '" />' . chr(10);
 }