1 | <?php |
||
14 | class Moo_EditableField extends DataObject |
||
15 | { |
||
16 | private static $db = [ |
||
17 | 'Name' => 'Varchar', |
||
18 | 'Title' => 'Varchar(255)', |
||
19 | 'Required' => 'Boolean', |
||
20 | 'CustomErrorMessage' => 'Varchar(255)', |
||
21 | 'CustomSettings' => 'Text', |
||
22 | ]; |
||
23 | private static $singular_name = 'Editable Field'; |
||
24 | private static $plural_name = 'Editable Fields'; |
||
25 | |||
26 | /** |
||
27 | * List of fields names part of the custom settings. |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $customSettingsFields = []; |
||
32 | |||
33 | /** |
||
34 | * Instance of FormField. |
||
35 | * |
||
36 | * @var FormField |
||
37 | */ |
||
38 | protected $field; |
||
39 | |||
40 | /** |
||
41 | * To prevent having tables for each fields minor settings we store it as |
||
42 | * a serialized array in the database. |
||
43 | * |
||
44 | * @return array Return all the Settings |
||
45 | */ |
||
46 | 8 | public function getSettings() |
|
50 | |||
51 | /** |
||
52 | * Set the custom settings for this field as we store the minor details in |
||
53 | * a serialized array in the database. |
||
54 | * |
||
55 | * @param array $settings the custom settings |
||
56 | */ |
||
57 | 8 | public function setSettings($settings = []) |
|
61 | |||
62 | /** |
||
63 | * Set a given field setting. Appends the option to the settings or overrides |
||
64 | * the existing value. |
||
65 | * |
||
66 | * @param string $key |
||
67 | * @param string $value |
||
68 | */ |
||
69 | 1 | public function setSetting($key, $value) |
|
76 | |||
77 | /** |
||
78 | * Return just one custom setting or empty string if it does |
||
79 | * not exist. |
||
80 | * |
||
81 | * @param string $setting |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | 3 | public function getSetting($setting) |
|
96 | |||
97 | /** |
||
98 | * Get the path to the icon for this field type, relative to the site root. |
||
99 | * |
||
100 | * @return string |
||
101 | */ |
||
102 | 1 | public function getIcon() |
|
106 | |||
107 | /** |
||
108 | * Get the icon HTML tag. |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | 1 | public function getIconTag() |
|
116 | |||
117 | 1 | public function getCMSFields() |
|
153 | |||
154 | 1 | public function getCMSValidator() |
|
160 | |||
161 | /** |
||
162 | * Returns the Title for rendering in the front-end (with XML values escaped). |
||
163 | * |
||
164 | * @return string |
||
165 | */ |
||
166 | 8 | public function getTitle() |
|
170 | |||
171 | /** |
||
172 | * Generate a name for the Setting field. |
||
173 | * |
||
174 | * @param string $field |
||
175 | * |
||
176 | * @return string |
||
177 | */ |
||
178 | 1 | public function getSettingName($field) |
|
182 | |||
183 | /** |
||
184 | * How to save the data submitted in this field into the database object |
||
185 | * which this field represents. |
||
186 | * |
||
187 | * Any class's which call this should also call |
||
188 | * {@link parent::populateFromPostData()} to ensure that this method is |
||
189 | * called |
||
190 | * |
||
191 | * @throws ValidationException |
||
192 | */ |
||
193 | 8 | public function onBeforeWrite() |
|
225 | |||
226 | /** |
||
227 | * Return a FormField. |
||
228 | * |
||
229 | * @return FormField |
||
230 | */ |
||
231 | 1 | public function getFormField() |
|
239 | |||
240 | /** |
||
241 | * Initiate a form field. |
||
242 | * |
||
243 | * @return FormField |
||
244 | */ |
||
245 | protected function initFormField() |
||
249 | |||
250 | /** |
||
251 | * Return the error message for this field. Either uses the custom |
||
252 | * one (if provided) or the default SilverStripe message. |
||
253 | * |
||
254 | * @return Varchar |
||
255 | */ |
||
256 | public function getErrorMessage() |
||
266 | |||
267 | 1 | public function onBeforeDuplicate(Moo_EditableField $field) |
|
272 | } |
||
273 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.