Conditions | 6 |
Paths | 1 |
Total Lines | 84 |
Code Lines | 53 |
Lines | 0 |
Ratio | 0 % |
Changes | 10 | ||
Bugs | 0 | Features | 2 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
57 | public function getCMSFields() |
||
58 | { |
||
59 | $this->beforeUpdateCMSFields(function (FieldList $fields) { |
||
60 | $resource = $this->DataResource(); |
||
61 | |||
62 | $fields->addFieldToTab( |
||
63 | 'Root.Data', |
||
64 | ResourceLocatorField::create('DataResource') |
||
65 | ->addExtraClass('form-field--no-divider') |
||
66 | ); |
||
67 | |||
68 | if ($resource && $resource->Identifier) { |
||
69 | $injector = Injector::inst(); |
||
70 | |||
71 | $columnsConfig = GridFieldConfig_RecordEditor::create() |
||
72 | ->addComponents([ |
||
73 | $injector->createWithArgs(GridFieldOrderableRows::class, ['Position']), |
||
74 | $injector->createWithArgs(GridFieldResourceTitle::class, [$resource]), |
||
75 | ]) |
||
76 | ->removeComponentsByType([ |
||
77 | GridFieldAddNewButton::class, |
||
78 | GridFieldDeleteAction::class, |
||
79 | GridFieldPageCount::class, |
||
80 | GridFieldToolbarHeader::class, |
||
81 | ]); |
||
82 | |||
83 | $columnsConfig->getComponentByType(GridFieldDetailForm::class) |
||
84 | ->setItemRequestClass(ResourceFieldItemRequest::class); |
||
85 | |||
86 | $resourceFields = GridField::create('DataColumns', '', $resource->Fields(), $columnsConfig); |
||
87 | $resourceFields->addExtraClass('ckan-columns'); |
||
88 | |||
89 | $resourceFields->setReadonlyComponents(array_merge( |
||
90 | $resourceFields->getReadonlyComponents(), |
||
91 | [GridFieldResourceTitle::class] |
||
92 | )); |
||
93 | |||
94 | // Configure inline editable checkboxes for the two boolean fields |
||
95 | $before = null; |
||
96 | $editableColumns = $injector->create(GridFieldEditableColumns::class); |
||
97 | foreach ($columnsConfig->getComponents() as $component) { |
||
98 | if ($before !== null) { |
||
99 | $before = $component; |
||
100 | break; |
||
101 | } |
||
102 | if ($component instanceof GridFieldDataColumns) { |
||
103 | $before = false; |
||
104 | $columns = $component->getDisplayFields($resourceFields); |
||
105 | |||
106 | // We only want to change the labels for the GridField view, not the model's edit form |
||
107 | $columns['ShowInResultsView'] = _t(__CLASS__ . '.IN_RESULTS', 'In Results'); |
||
108 | $columns['ShowInDetailView'] = _t(__CLASS__ . '.IN_DETAIL', 'In Detail'); |
||
109 | |||
110 | // Abbreviate the position title |
||
111 | $columns['Position'] = _t(__CLASS__ . '.POS', 'Pos.', 'Abbreviated version of position'); |
||
112 | |||
113 | $editable = array_flip(['ShowInResultsView', 'ShowInDetailView']); |
||
114 | $component->setDisplayFields(array_diff_key($columns, $editable)); |
||
115 | // set this way so that title translations are preserved |
||
116 | $editableColumns->setDisplayFields(array_intersect_key($columns, $editable)); |
||
117 | } |
||
118 | } |
||
119 | $columnsConfig->addComponent($editableColumns, $before); |
||
120 | $fields->addFieldToTab('Root.Data', $resourceFields); |
||
121 | |||
122 | $filtersConfig = GridFieldConfig_RecordEditor::create(); |
||
123 | $filtersConfig |
||
124 | ->removeComponentsByType([ |
||
125 | GridFieldAddExistingAutocompleter::class, |
||
126 | GridFieldAddNewButton::class |
||
127 | ]) |
||
128 | ->addComponents([ |
||
129 | $injector->create(GridFieldAddNewMultiClass::class), |
||
130 | $injector->createWithArgs(GridFieldOrderableRows::class, ['Order']), |
||
131 | ]); |
||
132 | |||
133 | $resourceFilters = GridField::create('DataFilters', '', $resource->Filters(), $filtersConfig); |
||
134 | $resourceFilters->addExtraClass('ckan-filters'); |
||
135 | |||
136 | $fields->addFieldToTab('Root.Filters', $resourceFilters); |
||
137 | } |
||
138 | }); |
||
139 | |||
140 | return parent::getCMSFields(); |
||
141 | } |
||
154 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths