1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace SunnySideUp\BuildDataObject; |
5
|
|
|
|
6
|
|
|
class PageBuildController extends BuildController |
7
|
|
|
{ |
8
|
|
|
protected $myBaseClass = 'Page'; |
9
|
|
|
|
10
|
|
View Code Duplication |
protected function primaryThingsToBuild() |
|
|
|
|
11
|
|
|
{ |
12
|
|
|
return [ |
13
|
|
|
['singular_name', 'text', '', false], |
14
|
|
|
['plural_name', 'text', '', false], |
15
|
|
|
['db', 'text', 'dbFields', true], |
16
|
|
|
['belongs_to', 'text', 'possibleRelations', true], |
17
|
|
|
['has_one', 'text', 'possibleRelations', true], |
18
|
|
|
['has_many', 'text', 'possibleRelations', true], |
19
|
|
|
['many_many', 'text', 'possibleRelations', true], |
20
|
|
|
['belongs_many_many', 'text', 'possibleRelations', true] |
21
|
|
|
]; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
protected function secondaryThingsToBuild() |
25
|
|
|
{ |
26
|
|
|
return [ |
27
|
|
|
['description', 'text', '', false], |
28
|
|
|
['can_create', 'TrueOrFalseList', '', false], |
29
|
|
|
['can_be_root', 'TrueOrFalseList', '', false], |
30
|
|
|
['allowed_children', 'allowedChildrenOptions', '', true], |
31
|
|
|
['default_child', 'SiteTreeList', '', false], |
32
|
|
|
['default_parent', 'SiteTreeList', '', false], |
33
|
|
|
['hide_ancestor', 'SiteTreeList', '', false], |
34
|
|
|
['defaults', 'myDbFields', 'text', true], |
35
|
|
|
['default_sort', 'MyDbFieldsWithDefaults', 'sortOptions', true], |
36
|
|
|
['indexes', 'myDbFieldsAndIndexes', 'indexOptions', true], |
37
|
|
|
['required_fields', 'myDbFieldsAndHasOnesWithIDs', 'requiredOptions', true], |
38
|
|
|
['field_labels', 'myAllFieldsWithoutBelongs', 'text', true], |
39
|
|
|
['field_labels_right', 'myAllFieldsWithoutBelongs', 'text', true], |
40
|
|
|
['searchable_fields', 'myDbFieldsAndHasOnesWithIDs', 'possibleSearchFilters', true], |
41
|
|
|
['summary_fields', 'myDbFieldsFancyWithBelongsWithBasicFields', 'text', true], |
42
|
|
|
['casting', 'text', 'dbFields', true], |
43
|
|
|
['canCreate', 'canOptions', '', false], |
44
|
|
|
['canView', 'canOptions', '', false], |
45
|
|
|
['canEdit', 'canOptions', '', false], |
46
|
|
|
['canDelete', 'canOptions', '', false] |
47
|
|
|
]; |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.