Completed
Pull Request — master (#107)
by
unknown
06:31 queued 02:27
created

SelectFilterConfig::setOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 2 Features 1
Metric Value
c 3
b 2
f 1
dl 0
loc 6
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Nayjest\Grids;
4
5
class SelectFilterConfig extends FilterConfig
6
{
7
    protected $template = '*.select';
8
9
    protected $options = [];
10
11
    protected $is_submitted_on_change = false;
12
13
    protected $size = null;
14
15
    protected $multipleMode = false;
16
17
    /**
18
     * Returns option items of html select tag.
19
     *
20
     * @return array
21
     */
22
    public function getOptions()
23
    {
24
        return $this->options;
25
    }
26
27
    /**
28
     * Sets option items for html select tag.
29
     *
30
     * @param array $options
31
     * @return $this
32
     */
33
    public function setOptions(array $options)
34
    {
35
        $this->options = $options;
36
37
        return $this;
38
    }
39
40
    /**
41
     * Returns true if form must be submitted immediately
42
     * when filter value selected.
43
     *
44
     * @return bool
45
     */
46
    public function isSubmittedOnChange()
47
    {
48
        return $this->is_submitted_on_change;
49
    }
50
51
    /**
52
     * Allows to submit form immediately when filter value selected.
53
     *
54
     * @param bool $isSubmittedOnChange
55
     *
56
     * @return $this
57
     */
58
    public function setSubmittedOnChange($isSubmittedOnChange)
59
    {
60
        $this->is_submitted_on_change = $isSubmittedOnChange;
61
        return $this;
62
    }
63
64
    /**
65
     * Sets the size of the select element.
66
     *
67
     * @param int $size
68
     *
69
     * @return $this
70
     */
71
    public function setSize($size)
72
    {
73
        $this->size = $size;
74
75
        return $this;
76
    }
77
78
    /**
79
     * Returns the size of the select element.
80
     *
81
     * @return int
82
     */
83
    public function getSize()
84
    {
85
        return $this->size;
86
    }
87
88
    /**
89
     * Enabled multiple mode.
90
     * This will switch the selected operator to IN, as any other operator does not work with multiple selections.
91
     *
92
     * @param $multipleMode
93
     *
94
     * @return $this
95
     */
96
    public function setMultipleMode($multipleMode)
97
    {
98
        $this->multipleMode = $multipleMode;
99
100
        if ($multipleMode) {
101
            $this->operator = FilterConfig::OPERATOR_IN;
102
        }
103
104
        return $this;
105
    }
106
107
    /**
108
     * Returns true if the multiple mode is enabled.
109
     *
110
     * @return bool
111
     */
112
    public function isMultipleMode()
113
    {
114
        return $this->multipleMode;
115
    }
116
}
117