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

EzAuthor   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 28
rs 10
wmc 5
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
B createValue() 0 18 5
1
<?php
2
3
namespace Kaliop\eZMigrationBundle\Core\ComplexField;
4
5
use eZ\Publish\Core\FieldType\Author\Value as AuthorValue;
6
use eZ\Publish\Core\FieldType\Author\Author;
7
use Kaliop\eZMigrationBundle\API\ComplexFieldInterface;
8
9
/**
10
 * @todo is this needed at all ?
11
 */
12
class EzAuthor extends AbstractComplexField implements ComplexFieldInterface
13
{
14
    /**
15
     * Creates a value object to use as the field value when setting an author field type.
16
     *
17
     * @param array $fieldValueArray The definition of teh field value, structured in the yml file
18
     * @param array $context The context for execution of the current migrations. Contains f.e. the path to the migration
19
     * @return AuthorValue
20
     */
21
    public function createValue(array $fieldValueArray, array $context = array())
22
    {
23
        $authors = array();
24
25
        /// @deprecated
26
        if (isset($fieldValueArray['authors'])) {
27
            foreach($fieldValueArray['authors'] as $author) {
28
                $authors[] = new Author($author);
29
            }
30
        } else if (is_array($fieldValueArray)) {
31
            /// same as what fromHash() does, really
32
            foreach($fieldValueArray as $author) {
33
                $authors[] = new Author($author);
34
            }
35
        }
36
37
        return new AuthorValue($authors);
38
    }
39
}
40