eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\UrlConverter::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)
    {
        $fieldValue->data = array('urlId' => $value->dataInt, 'text' => $value->dataText);
        $fieldValue->sortKey = false;
    }

Usage Example

Example #1
0
 /**
  * @group fieldType
  * @group url
  * @covers \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\UrlConverter::toFieldValue
  */
 public function testToFieldValue()
 {
     $text = "A link's text";
     $urlId = 842;
     $storageFieldValue = new StorageFieldValue();
     $storageFieldValue->dataText = $text;
     $storageFieldValue->dataInt = $urlId;
     $storageFieldValue->sortKeyString = false;
     $storageFieldValue->sortKeyInt = false;
     $fieldValue = new FieldValue();
     $this->converter->toFieldValue($storageFieldValue, $fieldValue);
     self::assertInternalType("array", $fieldValue->data);
     self::assertFalse($fieldValue->sortKey);
     self::assertSame($text, $fieldValue->data["text"]);
     self::assertEquals($urlId, $fieldValue->data["urlId"]);
 }