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 | protected $customSettingsFields = []; |
||
27 | /** |
||
28 | * Instance of FormField. |
||
29 | * |
||
30 | * @var FormField |
||
31 | */ |
||
32 | protected $field; |
||
33 | |||
34 | /** |
||
35 | * To prevent having tables for each fields minor settings we store it as |
||
36 | * a serialized array in the database. |
||
37 | * |
||
38 | * @return array Return all the Settings |
||
39 | */ |
||
40 | public function getSettings() |
||
44 | |||
45 | /** |
||
46 | * Set the custom settings for this field as we store the minor details in |
||
47 | * a serialized array in the database. |
||
48 | * |
||
49 | * @param array $settings the custom settings |
||
50 | */ |
||
51 | 3 | public function setSettings($settings = []) |
|
55 | |||
56 | /** |
||
57 | * Set a given field setting. Appends the option to the settings or overrides |
||
58 | * the existing value. |
||
59 | * |
||
60 | * @param string $key |
||
61 | * @param string $value |
||
62 | */ |
||
63 | public function setSetting($key, $value) |
||
70 | |||
71 | /** |
||
72 | * Return just one custom setting or empty string if it does |
||
73 | * not exist. |
||
74 | * |
||
75 | * @param string $setting |
||
76 | * |
||
77 | * @return string |
||
78 | */ |
||
79 | public function getSetting($setting) |
||
90 | |||
91 | /** |
||
92 | * Get the path to the icon for this field type, relative to the site root. |
||
93 | * |
||
94 | * @return string |
||
95 | */ |
||
96 | public function getIcon() |
||
100 | |||
101 | public function getIconTag() |
||
105 | |||
106 | public function getCMSFields() |
||
147 | |||
148 | public function getCMSValidator() |
||
154 | |||
155 | /** |
||
156 | * Returns the Title for rendering in the front-end (with XML values escaped). |
||
157 | * |
||
158 | * @return string |
||
159 | */ |
||
160 | 3 | public function getTitle() |
|
164 | |||
165 | /** |
||
166 | * Generate a name for the Setting field. |
||
167 | * |
||
168 | * @param string $field |
||
169 | * |
||
170 | * @return string |
||
171 | */ |
||
172 | public function getSettingName($field) |
||
176 | |||
177 | /** |
||
178 | * How to save the data submitted in this field into the database object |
||
179 | * which this field represents. |
||
180 | * |
||
181 | * Any class's which call this should also call |
||
182 | * {@link parent::populateFromPostData()} to ensure that this method is |
||
183 | * called |
||
184 | * |
||
185 | * @param array $data |
||
186 | * |
||
187 | * @throws ValidationException |
||
188 | */ |
||
189 | 12 | public function onBeforeWrite() |
|
209 | |||
210 | /** |
||
211 | * Return a FormField. |
||
212 | * |
||
213 | * @return FormField |
||
214 | */ |
||
215 | public function getFormField() |
||
223 | |||
224 | /** |
||
225 | * Initiate a form field. |
||
226 | * |
||
227 | * @return FormField |
||
228 | */ |
||
229 | protected function initFormField() |
||
233 | |||
234 | /** |
||
235 | * Return the error message for this field. Either uses the custom |
||
236 | * one (if provided) or the default SilverStripe message. |
||
237 | * |
||
238 | * @return Varchar |
||
239 | */ |
||
240 | public function getErrorMessage() |
||
250 | } |
||
251 |
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.