eZ\Publish\Core\FieldType\Url\Type::toPersistenceValue PHP Method

toPersistenceValue() public method

In this method the field type puts the data which is stored in the field of content in the repository into the property FieldValue::data. The format of $data is a primitive, an array (map) or an object, which is then canonically converted to e.g. json/xml structures by future storage engines without further conversions. For mapping the $data to the legacy database an appropriate Converter (implementing eZ\Publish\Core\Persistence\Legacy\FieldValue\Converter) has implemented for the field type. Note: $data should only hold data which is actually stored in the field. It must not hold data which is stored externally. The $externalData property in the FieldValue is used for storing data externally by the FieldStorage interface method storeFieldData. The FieldValuer::sortKey is build by the field type for using by sort operations.
See also: eZ\Publish\SPI\Persistence\Content\FieldValue
public toPersistenceValue ( eZ\Publish\SPI\FieldType\Value $value ) : eZ\Publish\SPI\Persistence\Content\FieldValue
$value eZ\Publish\SPI\FieldType\Value The value of the field type
return eZ\Publish\SPI\Persistence\Content\FieldValue the value processed by the storage engine
    public function toPersistenceValue(SPIValue $value)
    {
        if ($value === null) {
            return new FieldValue(array('data' => array(), 'externalData' => null, 'sortKey' => null));
        }
        return new FieldValue(array('data' => array('urlId' => null, 'text' => $value->text), 'externalData' => $value->link, 'sortKey' => $this->getSortInfo($value)));
    }