eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\SelectionConverter::toFieldValue PHP Method

toFieldValue() public method

Converts data from $value to $fieldValue.
public toFieldValue ( StorageFieldValue $value, eZ\Publish\SPI\Persistence\Content\FieldValue $fieldValue )
$value eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue
$fieldValue eZ\Publish\SPI\Persistence\Content\FieldValue
    public function toFieldValue(StorageFieldValue $value, FieldValue $fieldValue)
    {
        if ($value->dataText !== '') {
            $fieldValue->data = array_map('intval', explode('-', $value->dataText));
        } else {
            $fieldValue->data = array();
        }
        $fieldValue->sortKey = $value->sortKeyString;
    }

Usage Example

 /**
  * @group fieldType
  * @group selection
  * @covers \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\SelectionConverter::toFieldValue
  */
 public function testToFieldValueEmpty()
 {
     $storageFieldValue = new StorageFieldValue();
     $storageFieldValue->dataText = '';
     $storageFieldValue->sortKeyString = '';
     $expectedFieldValue = new FieldValue();
     $expectedFieldValue->data = array();
     $expectedFieldValue->sortKey = '';
     $actualFieldValue = new FieldValue();
     $this->converter->toFieldValue($storageFieldValue, $actualFieldValue);
     $this->assertEquals($expectedFieldValue, $actualFieldValue);
 }