-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCheckboxesField.php
More file actions
61 lines (55 loc) · 1.29 KB
/
CheckboxesField.php
File metadata and controls
61 lines (55 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace DesignPatterns\Behavioral\Visitor\FormFields;
use DesignPatterns\Behavioral\Visitor\FormField;
use DesignPatterns\Behavioral\Visitor\VisitorInterface;
/**
* A group of checkboxes. The value and a the view value are arrays.
*
* It corresponds to `ConcreteElement` in the Strategy pattern.
*
* @author Vlad Riabchenko <contact@vria.eu>
*/
class CheckboxesField extends FormField
{
/**
* Possible choices, the key of this array is a possible view value while the value is a possible model value:
*
* ```
* {
* 'Car' => Vehicle::CAR,
* 'Bike' => Vehicle::BIKE,
* 'Plane' => Vehicle::PLANE
* }
* ```
*
* @var array
*/
private $choices;
/**
* Accept a visitor that will transform or validate this choice field instance.
*
* @param VisitorInterface $visitor
*/
public function accept(VisitorInterface $visitor)
{
$visitor->visitCheckboxes($this);
}
/**
* Get possible choices.
*
* @return array
*/
public function getChoices()
{
return $this->choices;
}
/**
* Set possible choices.
*
* @param array $choices
*/
public function setChoices($choices)
{
$this->choices = $choices;
}
}