eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\CountryConverter::toStorageValue PHP Method

toStorageValue() public method

Converts data from $value to $storageFieldValue.
public toStorageValue ( eZ\Publish\SPI\Persistence\Content\FieldValue $value, StorageFieldValue $storageFieldValue )
$value eZ\Publish\SPI\Persistence\Content\FieldValue
$storageFieldValue eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue
    public function toStorageValue(FieldValue $value, StorageFieldValue $storageFieldValue)
    {
        $storageFieldValue->dataText = empty($value->data) ? '' : implode(',', $value->data);
        $storageFieldValue->sortKeyString = $value->sortKey;
    }

Usage Example

Beispiel #1
0
 /**
  * @group fieldType
  * @group country
  * @dataProvider providerForTestToStorageValue
  * @covers \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\CountryConverter::toStorageValue
  */
 public function testToStorageValue($data, $sortKey, $dataText, $sortKeyString)
 {
     $value = new FieldValue();
     $value->data = $data;
     $value->sortKey = $sortKey;
     $storageFieldValue = new StorageFieldValue();
     $this->converter->toStorageValue($value, $storageFieldValue);
     self::assertSame($dataText, $storageFieldValue->dataText);
     self::assertSame($sortKeyString, $storageFieldValue->sortKeyString);
 }