eZ\Publish\Core\Persistence\Legacy\Content\FieldHandler::copyField PHP Method

copyField() protected method

Used by self::createNewFields() and self::updateFields()
protected copyField ( eZ\Publish\SPI\Persistence\Content\Field $originalField, string $languageCode, eZ\Publish\SPI\Persistence\Content $content )
$originalField eZ\Publish\SPI\Persistence\Content\Field
$languageCode string
$content eZ\Publish\SPI\Persistence\Content
    protected function copyField(Field $originalField, $languageCode, Content $content)
    {
        $originalField->versionNo = $content->versionInfo->versionNo;
        $field = clone $originalField;
        $field->languageCode = $languageCode;
        $field->id = $this->contentGateway->insertNewField($content, $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->copyFieldData($content->versionInfo, $field, $originalField) === true) {
            $this->contentGateway->updateField($field, $this->mapper->convertToStorageValue($field));
        }
        $content->fields[] = $field;
    }