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

toStorageValue() public method

Note: You should not throw on validation here, as it is implicitly used by ContentService->createContentDraft(). Rather allow invalid value or omit it to let validation layer in FieldType handle issues when user tried to publish the given draft.
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);

Usage Example

 /**
  * Inserts given $field and appends it to the given $content field collection.
  *
  * @param \eZ\Publish\SPI\Persistence\Content $content
  * @param \eZ\Publish\SPI\Persistence\Content\Field $field
  *
  * @return void
  */
 protected function insertField(Content $content, Field $field)
 {
     $storageValue = new StorageFieldValue();
     $this->fieldValueConverter->toStorageValue($field->value, $storageValue);
     $field->id = $this->contentGateway->insertNewField($content, $field, $storageValue);
     // If the storage handler returns true, it means that $field value has been modified
     // So we need to update it in order to store those modifications
     // Field converter is called once again via the Mapper
     if ($this->storageHandler->storeFieldData($content->versionInfo, $field) === true) {
         $storageValue = new StorageFieldValue();
         $this->fieldValueConverter->toStorageValue($field->value, $storageValue);
         if ($this->fieldDefinition->isTranslatable) {
             $this->contentGateway->updateField($field, $storageValue);
         } else {
             $this->contentGateway->updateNonTranslatableField($field, $storageValue, $content->versionInfo->contentInfo->id);
         }
     }
     $content->fields[] = $field;
 }
All Usage Examples Of eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter::toStorageValue