Completed
Push — master ( 12f48c...b47ac0 )
by Gaetano
06:59
created

EzRelation   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 20
rs 10
wmc 2
lcom 1
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A createValue() 0 10 2
1
<?php
2
3
namespace Kaliop\eZMigrationBundle\Core\ComplexField;
4
5
use eZ\Publish\Core\FieldType\Relation\Value;
6
use Kaliop\eZMigrationBundle\API\ComplexFieldInterface;
7
8
class EzRelation extends AbstractComplexField implements ComplexFieldInterface
9
{
10
    /**
11
     * Creates a value object to use as the field value when setting an ez page field type.
12
     *
13
     * @param array $fieldValueArray The definition of the field value, structured in the yml file
14
     * @param array $context The context for execution of the current migrations. Contains f.e. the path to the migration
15
     * @return PageValue
16
     */
17
    public function createValue(array $fieldValueArray, array $context = array())
18
    {
19
        $id = $fieldValueArray['destinationContentId'];
20
21
        if ($this->referenceResolver->isReference($id)) {
22
            $id = $this->referenceResolver->getReferenceValue($id);
23
        }
24
25
        return new Value($id);
26
    }
27
}
28