|
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) |
|
|
|
|
|
|
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
|
|
|
|
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.