1 | <?php |
||
42 | abstract class Element extends Specs |
||
43 | { |
||
44 | use HasAttributesTrait; |
||
45 | use HasDataTrait; |
||
46 | |||
47 | /** |
||
48 | * Name of the field (identifier of the element in the form's child list) |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | protected $name; |
||
53 | |||
54 | /** |
||
55 | * |
||
56 | * @param string $name |
||
57 | * Name of the form element that will make it identifiable |
||
58 | * @param array $specs |
||
59 | * Specification for the element (attributes, parents, etc) |
||
60 | */ |
||
61 | 48 | function __construct($name, $specs = array()) |
|
69 | |||
70 | /** |
||
71 | * Returns the default element specifications |
||
72 | * To be used for easily extending objects |
||
73 | * |
||
74 | * @return array |
||
75 | */ |
||
76 | 8 | protected function getDefaultSpecs() |
|
80 | |||
81 | /** |
||
82 | * Retrieve the name of the form's element as registered within the form |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | 14 | function getName() |
|
90 | |||
91 | /** |
||
92 | * Sets the group this element belongs to |
||
93 | * |
||
94 | * @param null|string $group |
||
95 | * |
||
96 | * @return $this |
||
97 | */ |
||
98 | 1 | function setGroup($group = null) |
|
104 | |||
105 | /** |
||
106 | * Retrieve the group this element belongs to |
||
107 | * |
||
108 | * @return null|string |
||
109 | */ |
||
110 | 9 | function getGroup() |
|
114 | |||
115 | /** |
||
116 | * Sets the widget for this element |
||
117 | * |
||
118 | * @param null|string $widget |
||
119 | * |
||
120 | * @return $this |
||
121 | */ |
||
122 | 40 | function setWidget($widget = null) |
|
128 | |||
129 | /** |
||
130 | * Retrieve the widget type for this element |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | function getWidget() |
||
138 | |||
139 | /** |
||
140 | * Sets the display priority for this element |
||
141 | * |
||
142 | * @param integer $priority |
||
143 | * |
||
144 | * @return $this |
||
145 | */ |
||
146 | 7 | function setPosition($priority = 0) |
|
152 | |||
153 | /** |
||
154 | * Retrieve display position for this element |
||
155 | * |
||
156 | * @return integer |
||
157 | */ |
||
158 | function getPosition() |
||
162 | |||
163 | |||
164 | /** |
||
165 | * Prepares the input filter to receive data and be rendered |
||
166 | * It attaches the filters, validation rules, upload handler for the element |
||
167 | * |
||
168 | * @param InputFilter $inputFilter |
||
169 | */ |
||
170 | 9 | function prepareInputFilter(InputFilter $inputFilter) |
|
179 | |||
180 | } |
||
181 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.