Completed
Push — develop ( c603db...77b219 )
by
unknown
16:24 queued 08:23
created

UserStatusFieldset::getViewPartial()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
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
 */
9
10
namespace Auth\Form;
11
12
use Core\Entity\Hydrator\EntityHydrator;
13
use Zend\Form\Fieldset;
14
use Core\Form\ViewPartialProviderInterface;
15
16
class UserStatusFieldset extends Fieldset implements ViewPartialProviderInterface
17
{
18
19
    /**
20
     * View script for rendering
21
     *
22
     * @var string
23
     */
24
    protected $viewPartial = 'form/auth/status';
25
    
26
    /**
27
     * @var array
28
     */
29
    protected $statusOptions = [];
30
31
    /**
32
     * @param String $partial
33
     *
34
     * @return $this
35
     */
36
    public function setViewPartial($partial)
37
    {
38
        $this->viewPartial = $partial;
39
40
        return $this;
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    public function getViewPartial()
47
    {
48
        return $this->viewPartial;
49
    }
50
51
    /**
52
     * @return \Zend\Hydrator\HydratorInterface
53
     */
54
    public function getHydrator()
55
    {
56
        if (!$this->hydrator) {
57
            $hydrator = new EntityHydrator();
58
            $this->setHydrator($hydrator);
59
        }
60
61
        return $this->hydrator;
62
    }
63
64
    /**
65
	 * @param array $statusOptions
66
	 * @return UserStatusFieldset
67
	 */
68
	public function setStatusOptions(array $statusOptions)
69
	{
70
		$this->statusOptions = $statusOptions;
71
		
72
		return $this;
73
	}
74
75 View Code Duplication
	public function init()
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...
76
    {
77
        $this->setName('status');
78
79
        $this->add(
80
            [
81
                'name'       => 'status',
82
                'type'       => 'Zend\Form\Element\Select',
83
                'options'    => [
84
                    'label'         => /*@translate */ 'Status',
85
                    'value_options' => $this->statusOptions
86
                ],
87
                'attributes' => [
88
                    'data-placeholder' => /*@translate*/ 'please select',
89
                    'data-allowclear' => 'false',
90
                    'data-searchbox' => -1,  // hide the search box
91
                    'required' => true, // mark label as required
92
                ],
93
            ]
94
        );
95
    }
96
}
97