public function generateTrustedPropertiesToken($formFieldNames, $fieldNamePrefix = '')
    {
        $formFieldArray = [];
        foreach ($formFieldNames as $formField) {
            $formFieldParts = explode('[', $formField);
            $currentPosition =& $formFieldArray;
            $formFieldPartsCount = count($formFieldParts);
            for ($i = 0; $i < $formFieldPartsCount; $i++) {
                $formFieldPart = $formFieldParts[$i];
                $formFieldPart = rtrim($formFieldPart, ']');

                if (!is_array($currentPosition)) {
                    throw new InvalidArgumentForHashGenerationException('The form field "' . $formField . '" is declared as array, but it collides with a previous form field of the same name which declared the field as string. This is an inconsistency you need to fix inside your Fluid form. (String overridden by Array)', 1255072196);
                }

                if ($i === count($formFieldParts) - 1) {
                    if (isset($currentPosition[$formFieldPart]) && is_array($currentPosition[$formFieldPart])) {
                        throw new InvalidArgumentForHashGenerationException('The form field "' . $formField . '" is declared as string, but it collides with a previous form field of the same name which declared the field as array. This is an inconsistency you need to fix inside your Fluid form. (Array overridden by String)', 1255072587);
                    }
                    // Last iteration - add a string
                    if ($formFieldPart === '') {
                        $currentPosition[] = 1;
                    } else {
                        $currentPosition[$formFieldPart] = 1;
                    }
                } else {
                    if ($formFieldPart === '') {
                        throw new InvalidArgumentForHashGenerationException('The form field "' . $formField . '" is invalid. Reason: "[]" used not as last argument, but somewhere in the middle (like foo[][bar]).', 1255072832);
                    }
                    if (!isset($currentPosition[$formFieldPart])) {
                        $currentPosition[$formFieldPart] = [];
                    }
                    $currentPosition =& $currentPosition[$formFieldPart];
                }
            }
        }
        if ($fieldNamePrefix !== '') {
            $formFieldArray = (isset($formFieldArray[$fieldNamePrefix]) ? $formFieldArray[$fieldNamePrefix] : []);
        }
        return $this->serializeAndHashFormFieldArray($formFieldArray);
    }
public function generateTrustedPropertiesToken($formFieldNames, $fieldNamePrefix = '')
    {
        $formFieldArray = [];
        foreach ($formFieldNames as $formField) {
            $formFieldParts = explode('[', $formField);
            $currentPosition =& $formFieldArray;
            $formFieldPartsCount = count($formFieldParts);
            for ($i = 0; $i < $formFieldPartsCount; $i++) {
                $formFieldPart = $formFieldParts[$i];
                $formFieldPart = rtrim($formFieldPart, ']');

                if (!is_array($currentPosition)) {
                    throw new InvalidArgumentForHashGenerationException('The form field "' . $formField . '" is declared as array, but it collides with a previous form field of the same name which declared the field as string. This is an inconsistency you need to fix inside your Fluid form. (String overridden by Array)', 1255072196);
                }

                if ($i === count($formFieldParts) - 1) {
                    if (isset($currentPosition[$formFieldPart]) && is_array($currentPosition[$formFieldPart])) {
                        throw new InvalidArgumentForHashGenerationException('The form field "' . $formField . '" is declared as string, but it collides with a previous form field of the same name which declared the field as array. This is an inconsistency you need to fix inside your Fluid form. (Array overridden by String)', 1255072587);
                    }
                    // Last iteration - add a string
                    if ($formFieldPart === '') {
                        $currentPosition[] = 1;
                    } else {
                        $currentPosition[$formFieldPart] = 1;
                    }
                } else {
                    if ($formFieldPart === '') {
                        throw new InvalidArgumentForHashGenerationException('The form field "' . $formField . '" is invalid. Reason: "[]" used not as last argument, but somewhere in the middle (like foo[][bar]).', 1255072832);
                    }
                    if (!isset($currentPosition[$formFieldPart])) {
                        $currentPosition[$formFieldPart] = [];
                    }
                    $currentPosition =& $currentPosition[$formFieldPart];
                }
            }
        }
        if ($fieldNamePrefix !== '') {
            $formFieldArray = (isset($formFieldArray[$fieldNamePrefix]) ? $formFieldArray[$fieldNamePrefix] : []);
        }
        return $this->serializeAndHashFormFieldArray($formFieldArray);
    }
public function generateTrustedPropertiesToken ( $ formFieldNames , $ fieldNamePrefix = '' ) { $ formFieldArray = [ ] ; foreach ( $ formFieldNames as $ formField ) { $ formFieldParts = explode ( '[' , $ formField ) ; $ currentPosition = & $ formFieldArray ; $ formFieldPartsCount = count ( $ formFieldParts ) ; for ( $ i = 0 ; $ i < $ formFieldPartsCount ; $ i ++ ) { $ formFieldPart = $ formFieldParts [ $ i ] ; $ formFieldPart = rtrim ( $ formFieldPart , ']' ) ; if ( ! is_array ( $ currentPosition ) ) { throw new InvalidArgumentForHashGenerationException ( 'The form field "' . $ formField . '" is declared as array, but it collides with a previous form field of the same name which declared the field as string. This is an inconsistency you need to fix inside your Fluid form. (String overridden by Array)' , 1255072196 ) ; } if ( $ i === count ( $ formFieldParts ) - 1 ) { if ( isset ( $ currentPosition [ $ formFieldPart ] ) && is_array ( $ currentPosition [ $ formFieldPart ] ) ) { throw new InvalidArgumentForHashGenerationException ( 'The form field "' . $ formField . '" is declared as string, but it collides with a previous form field of the same name which declared the field as array. This is an inconsistency you need to fix inside your Fluid form. (Array overridden by String)' , 1255072587 ) ; } // Last iteration - add a string if ( $ formFieldPart === '' ) { $ currentPosition [ ] = 1 ; } else { $ currentPosition [ $ formFieldPart ] = 1 ; } } else { if ( $ formFieldPart === '' ) { throw new InvalidArgumentForHashGenerationException ( 'The form field "' . $ formField . '" is invalid. Reason: "[]" used not as last argument, but somewhere in the middle (like foo[][bar]).' , 1255072832 ) ; } if ( ! isset ( $ currentPosition [ $ formFieldPart ] ) ) { $ currentPosition [ $ formFieldPart ] = [ ] ; } $ currentPosition = & $ currentPosition [ $ formFieldPart ] ; } } } if ( $ fieldNamePrefix !== '' ) { $ formFieldArray = ( isset ( $ formFieldArray [ $ fieldNamePrefix ] ) ? $ formFieldArray [ $ fieldNamePrefix ] : [ ] ) ; } return $ this -> serializeAndHashFormFieldArray ( $ formFieldArray ) ; }
Generate a request hash for a list of form fields

@param array $formFieldNames Array of form fields
@param string $fieldNamePrefix
@return string trusted properties token
@throws InvalidArgumentForHashGenerationException
Generate a request hash for a list of form fields