Completed
Push — develop ( a791bf...3a1732 )
by
unknown
17:30 queued 08:09
created

PreviewFieldset::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 23
rs 9.0856
cc 1
eloc 15
nc 1
nop 0
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
7
 * @license   MIT
8
 * @author    [email protected]
9
 */
10
11
namespace Jobs\Form;
12
13
use Core\Entity\DraftableEntityInterface;
14
use Core\Form\ViewPartialProviderInterface;
15
use Core\Form\ViewPartialProviderTrait;
16
use Zend\Form\Fieldset;
17
use Core\Entity\Hydrator\EntityHydrator;
18
19
/**
20
 * Defines the formular files of the 3rd formular for entering a job opening
21
 *
22
 * @package Jobs\Form
23
 */
24
class PreviewFieldset extends Fieldset implements ViewPartialProviderInterface
25
{
26
    use ViewPartialProviderTrait;
27
28
    protected $defaultPartial = 'jobs/form/preview';
29
30
    public function getHydrator()
31
    {
32
        if (!$this->hydrator) {
33
            $hydrator = new EntityHydrator();
34
            $this->setHydrator($hydrator);
35
        }
36
        return $this->hydrator;
37
    }
38
39
    public function init()
40
    {
41
        $this->setAttribute('id', 'jobpreview-fieldset');
42
43
        $this->add(
44
            array(
45
            'type' => 'infocheckbox',
46
            'name' => 'termsAccepted',
47
            'options' => array(
48
                'headline' => /*@translate*/ 'Terms and conditions',
49
                'long_label' => /*@translate*/ 'I have read the %s and accept it',
50
                'linktext' => /*@translate*/ 'terms an conditions',
51
                'route' => 'lang/content',
52
                'params' => array(
53
                    'view' => 'jobs-terms-and-conditions'
54
                )
55
            ),
56
            'attributes' => array(
57
                'data-trigger' => 'submit',
58
            ),
59
            )
60
        );
61
    }
62
63 View Code Duplication
    public function setObject($object)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
64
    {
65
        if ($object instanceof DraftableEntityInterface && !$object->isDraft()) {
66
            foreach ($this as $element) {
67
                $element->setAttribute('disabled', 'disabled');
68
            }
69
        }
70
        return parent::setObject($object);
71
    }
72
}
73