Completed
Push — develop ( 69bf64...c61561 )
by
unknown
09:01
created

SkillFieldset   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getHydrator() 0 12 2
B init() 0 34 1
1
<?php
2
3
namespace Cv\Form;
4
5
use Zend\Form\Fieldset;
6
use Cv\Entity\Skill as SkillEntity;
7
use Core\Entity\Hydrator\EntityHydrator;
8
use Core\Form\Hydrator\Strategy\CollectionStrategy;
9
10
class SkillFieldset extends Fieldset
11
{
12
13
    public function getHydrator()
14
    {
15
        if (!$this->hydrator) {
16
            $hydrator = new EntityHydrator();
17
            $collectionStrategy = new CollectionStrategy();
18
            $hydrator->addStrategy('nativeLanguages', $collectionStrategy)
19
                ->addStrategy('languageSkills', $collectionStrategy);
20
            
21
            $this->setHydrator($hydrator);
22
        }
23
        return $this->hydrator;
24
    }
25
    
26
    public function init()
27
    {
28
        $this->setName('skill')
29
            ->setLabel('Languages')
30
            ->setObject(new SkillEntity());
31
        
32
        $this->add(array(
33
            'type' => 'Collection',
34
            'name' => 'nativeLanguages',
35
            'options' => array(
36
                'label' => /*@translate */ 'Native Language',
37
                'count' => 1,
38
                'should_create_template' => true,
39
                'allow_add' => true,
40
                'target_element' => array(
41
                    'type' => 'NativeLanguageFieldset'
42
                )
43
            )
44
        ));
45
        
46
        $this->add(array(
47
            'type' => 'Collection',
48
            'name' => 'languageSkills',
49
            'options' => array(
50
                'label' => /*@translate */ 'Other languages',
51
                'count' => 1,
52
                'should_create_template' => true,
53
                'allow_add' => true,
54
                'target_element' => array(
55
                    'type' => 'LanguageSkillFieldset'
56
                )
57
            )
58
        ));
59
    }
60
}
61