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

SkillFieldset::init()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 34
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 34
rs 8.8571
cc 1
eloc 24
nc 1
nop 0
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