Stores data from $field in its corresponding external storage.
public storeFieldData ( eZ\Publish\SPI\Persistence\Content\VersionInfo $versionInfo, eZ\Publish\SPI\Persistence\Content\Field $field ) | ||
$versionInfo | eZ\Publish\SPI\Persistence\Content\VersionInfo | |
$field | eZ\Publish\SPI\Persistence\Content\Field |
/** * Updates an existing field in the database. * * Used by self::createNewFields() and self::updateFields() * * @param \eZ\Publish\SPI\Persistence\Content\Field $field * @param \eZ\Publish\SPI\Persistence\Content $content * * @return void */ protected function updateField(Field $field, Content $content) { $this->contentGateway->updateField($field, $this->mapper->convertToStorageValue($field)); // 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) { $this->contentGateway->updateField($field, $this->mapper->convertToStorageValue($field)); } }
/** * 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; }
/** * Inserts given $field to the internal and external storage. * * If $field->id is null, creating new field id will be created. * Otherwise it will be inserted for the given $content version, reusing existing Field id. * * @param \eZ\Publish\SPI\Persistence\Content $content * @param \eZ\Publish\SPI\Persistence\Content\Field $field * * @return int The ID of the field that was inserted */ protected function insertField(Content $content, Field $field) { $storageValue = new StorageFieldValue(); $this->fieldValueConverter->toStorageValue($field->value, $storageValue); if (isset($field->id)) { // Insert with existing Field id and given Content version number $this->contentGateway->insertExistingField($content, $field, $storageValue); } else { // Insert with creating new Field id and given Content version number $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); $this->contentGateway->updateField($field, $storageValue); } return $field->id; }