Completed
Push — develop ( 6abf52...f3539b )
by
unknown
27:56 queued 14:17
created

TemplateLabelHydrator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4286
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013-2015 Cross Solution (http://cross-solution.de)
7
 * @license   MIT
8
 * @author    [email protected]
9
 */
10
11
namespace Jobs\Form\Hydrator;
12
13
use Jobs\Entity;
14
use Core\Entity\Hydrator\EntityHydrator;
15
use Organizations\Repository;
16
17
class TemplateLabelHydrator extends EntityHydrator
18
{
19
    public function __construct()
20
    {
21
        parent::__construct();
22
        $this->init();
23
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28
    public function extract($object)
29
    {
30
        $data = array();
31
32
        /** @var Entity\Job $object */
33
        if ($object->getOrganization()) {
34
            $data['description-label-requirements'] = $object->getOrganization()->getTemplate()->getLabelRequirements();
35
            $data['description-label-qualifications'] = $object->getOrganization()->getTemplate()->getLabelQualifications();
36
            $data['description-label-benefits'] = $object->getOrganization()->getTemplate()->getLabelBenefits();
37
        }
38
        return $data;
39
    }
40
41
    public function hydrate(array $data, $object)
42
    {
43
        $object = parent::hydrate($data, $object);
44
        /* @var \Organizations\Entity\Template  $template */
45
        $template=$object->getOrganization()->getTemplate();
46
        if (isset($data['description-label-requirements'])){
47
            $template->setLabelRequirements($data['description-label-requirements']);
48
        }
49
        if (isset($data['description-label-qualifications'])) {
50
            $template->setLabelQualifications($data['description-label-qualifications']);
51
        }
52
        if (isset($data['description-label-benefits'])) {
53
            $template->setLabelBenefits($data['description-label-benefits']);
54
        }
55
        return $object;
56
    }
57
}
58