public function hashToFieldValue($fieldValue, array $context = array())
    {
        if ($fieldValue === null) {
            return new SelectionValue();
        }

        // allow user to pass in a single value
        if (is_string($fieldValue) || is_int($fieldValue)) {
            $fieldValue = array($fieldValue);
        }

        // allow user to pass in selection values by name
        $fieldSettings = null;
        foreach($fieldValue as $key => $val) {

            $val = $this->referenceResolver->resolveReference($val);

            if (is_string($val)) {
                if (ctype_digit($val)) {
                    $fieldValue[$key] = (int)$val;
                } else {
                    if ($fieldSettings === null) {
                        $fieldSettings = $this->loadFieldSettings($context['contentTypeIdentifier'], $context['fieldIdentifier']);
                    }
                    foreach($fieldSettings['options'] as $pos => $name) {
                        if ($name === $val) {
                            $fieldValue[$key] = $pos;
                            break;
                        }
                    }
                }
            }
        }

        return new SelectionValue($fieldValue);
    }
public function hashToFieldValue($fieldValue, array $context = array())
    {
        if ($fieldValue === null) {
            return new SelectionValue();
        }

        // allow user to pass in a single value
        if (is_string($fieldValue) || is_int($fieldValue)) {
            $fieldValue = array($fieldValue);
        }

        // allow user to pass in selection values by name
        $fieldSettings = null;
        foreach($fieldValue as $key => $val) {

            $val = $this->referenceResolver->resolveReference($val);

            if (is_string($val)) {
                if (ctype_digit($val)) {
                    $fieldValue[$key] = (int)$val;
                } else {
                    if ($fieldSettings === null) {
                        $fieldSettings = $this->loadFieldSettings($context['contentTypeIdentifier'], $context['fieldIdentifier']);
                    }
                    foreach($fieldSettings['options'] as $pos => $name) {
                        if ($name === $val) {
                            $fieldValue[$key] = $pos;
                            break;
                        }
                    }
                }
            }
        }

        return new SelectionValue($fieldValue);
    }
public function hashToFieldValue ( $ fieldValue , array $ context = array ( ) ) { if ( $ fieldValue === null ) { return new SelectionValue ( ) ; } // allow user to pass in a single value if ( is_string ( $ fieldValue ) || is_int ( $ fieldValue ) ) { $ fieldValue = array ( $ fieldValue ) ; } // allow user to pass in selection values by name $ fieldSettings = null ; foreach ( $ fieldValue as $ key => $ val ) { $ val = $ this -> referenceResolver -> resolveReference ( $ val ) ; if ( is_string ( $ val ) ) { if ( ctype_digit ( $ val ) ) { $ fieldValue [ $ key ] = ( int ) $ val ; } else { if ( $ fieldSettings === null ) { $ fieldSettings = $ this -> loadFieldSettings ( $ context [ 'contentTypeIdentifier' ] , $ context [ 'fieldIdentifier' ] ) ; } foreach ( $ fieldSettings [ 'options' ] as $ pos => $ name ) { if ( $ name === $ val ) { $ fieldValue [ $ key ] = $ pos ; break ; } } } } } return new SelectionValue ( $ fieldValue ) ; }
Creates a value object to use as the field value when setting a selection field type.

@param $fieldValue int|string|string[]|int[] should all work
@param array $context The context for execution of the current migrations. Contains f.e. the path to the migration
@return SelectionValue
Creates a value object to use as the field value when setting a selection field type .