Code Duplication    Length = 20-21 lines in 3 locations

eZ/Publish/Core/Persistence/Legacy/Content/FieldHandler.php 3 locations

@@ 170-189 (lines=20) @@
167
     * @param \eZ\Publish\SPI\Persistence\Content\Field $field
168
     * @param \eZ\Publish\SPI\Persistence\Content $content
169
     */
170
    protected function createNewField(Field $field, Content $content)
171
    {
172
        $field->versionNo = $content->versionInfo->versionNo;
173
174
        $field->id = $this->contentGateway->insertNewField(
175
            $content,
176
            $field,
177
            $this->mapper->convertToStorageValue($field)
178
        );
179
180
        // If the storage handler returns true, it means that $field value has been modified
181
        // So we need to update it in order to store those modifications
182
        // Field converter is called once again via the Mapper
183
        if ($this->storageHandler->storeFieldData($content->versionInfo, $field) === true) {
184
            $this->contentGateway->updateField(
185
                $field,
186
                $this->mapper->convertToStorageValue($field)
187
            );
188
        }
189
    }
190
191
    /**
192
     * @param array $fields
@@ 277-297 (lines=21) @@
274
     * @param Field $field
275
     * @param Content $content
276
     */
277
    protected function createExistingFieldInNewVersion(Field $field, Content $content)
278
    {
279
        $originalField = clone $field;
280
        $field->versionNo = $content->versionInfo->versionNo;
281
282
        $this->contentGateway->insertExistingField(
283
            $content,
284
            $field,
285
            $this->mapper->convertToStorageValue($field)
286
        );
287
288
        // If the storage handler returns true, it means that $field value has been modified
289
        // So we need to update it in order to store those modifications
290
        // Field converter is called once again via the Mapper
291
        if ($this->storageHandler->copyFieldData($content->versionInfo, $field, $originalField) === true) {
292
            $this->contentGateway->updateField(
293
                $field,
294
                $this->mapper->convertToStorageValue($field)
295
            );
296
        }
297
    }
298
299
    /**
300
     * Performs external loads for the fields in $content.
@@ 393-412 (lines=20) @@
390
     * @param \eZ\Publish\SPI\Persistence\Content\Field $originalField
391
     * @param \eZ\Publish\SPI\Persistence\Content $content
392
     */
393
    protected function updateCopiedField(Field $field, Field $updateField, Field $originalField, Content $content)
394
    {
395
        $field->versionNo = $content->versionInfo->versionNo;
396
        $field->value = clone $updateField->value;
397
398
        $this->contentGateway->updateField(
399
            $field,
400
            $this->mapper->convertToStorageValue($field)
401
        );
402
403
        // If the storage handler returns true, it means that $field value has been modified
404
        // So we need to update it in order to store those modifications
405
        // Field converter is called once again via the Mapper
406
        if ($this->storageHandler->copyFieldData($content->versionInfo, $field, $originalField) === true) {
407
            $this->contentGateway->updateField(
408
                $field,
409
                $this->mapper->convertToStorageValue($field)
410
            );
411
        }
412
    }
413
414
    /**
415
     * Returns given $fields structured in hash array with field definition ids and language codes as keys.