eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\DateAndTimeConverter::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->dataInt === null) {
            return;
        }
        $fieldValue->data = array('rfc850' => null, 'timestamp' => $value->dataInt);
        $fieldValue->sortKey = $value->sortKeyInt;
    }

Usage Example

 /**
  * @group fieldType
  * @group dateTime
  * @covers \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\DateAndTimeConverter::toFieldValue
  */
 public function testToFieldValue()
 {
     $storageFieldValue = new StorageFieldValue();
     $storageFieldValue->dataInt = $this->date->getTimestamp();
     $storageFieldValue->sortKeyString = '';
     $storageFieldValue->sortKeyInt = $this->date->getTimestamp();
     $fieldValue = new FieldValue();
     $this->converter->toFieldValue($storageFieldValue, $fieldValue);
     self::assertSame(array('rfc850' => null, 'timestamp' => 1048633200), $fieldValue->data);
     self::assertSame($storageFieldValue->dataInt, $fieldValue->data['timestamp']);
     self::assertSame($storageFieldValue->sortKeyInt, $fieldValue->sortKey);
 }