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

EzRelation::createValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 5
c 1
b 0
f 1
nc 2
nop 2
dl 0
loc 10
rs 9.4285
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