Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
9 | class DataObjectOneFieldOneRecordUpdateController extends DataObjectSortBaseClass |
||
10 | { |
||
11 | private static $allowed_actions = array( |
||
|
|||
12 | "onefieldform" => 'DATA_OBJECT_SORT_AND_EDIT_PERMISSION', |
||
13 | "show" => 'DATA_OBJECT_SORT_AND_EDIT_PERMISSION', |
||
14 | "save" => 'DATA_OBJECT_SORT_AND_EDIT_PERMISSION' |
||
15 | ); |
||
16 | |||
17 | /** |
||
18 | * |
||
19 | * make sure to also change in routes if you change this link |
||
20 | * @var string |
||
21 | */ |
||
22 | private static $url_segment = 'dataobjectonefieldonerecordupdate'; |
||
23 | |||
24 | /** |
||
25 | * get a link |
||
26 | * @param string $ClassName |
||
27 | * @param string $FieldName |
||
28 | * @param string $recordID |
||
29 | * |
||
30 | * @return string |
||
31 | */ |
||
32 | public static function popup_link_only($ClassName, $FieldName, $recordID) |
||
38 | |||
39 | /** |
||
40 | * get a link |
||
41 | * @param string $ClassName |
||
42 | * @param string $FieldName |
||
43 | * @param string $recordID |
||
44 | * @param string $linkText |
||
45 | * @return string |
||
46 | */ |
||
47 | View Code Duplication | public static function popup_link($ClassName, $FieldName, $recordID, $linkText = 'click here to edit') |
|
54 | |||
55 | View Code Duplication | public function init() |
|
70 | |||
71 | public function onefieldform() |
||
103 | |||
104 | public function save($data, $form) |
||
119 | } |
||
120 |