Conditions | 6 |
Paths | 1 |
Total Lines | 57 |
Code Lines | 35 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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 |
||
46 | public function getCMSFields() |
||
47 | { |
||
48 | $this->beforeUpdateCMSFields(function (FieldList $fields) { |
||
49 | $resource = $this->DataResource(); |
||
50 | $fields->addFieldToTab('Root.Data', ResourceLocatorField::create('DataResource')); |
||
51 | |||
52 | if ($resource && $resource->Identifier) { |
||
53 | $injector = Injector::inst(); |
||
54 | |||
55 | $columnsConfig = GridFieldConfig_RecordEditor::create() |
||
56 | ->addComponent($injector->createWithArgs(GridFieldOrderableRows::class, ['Order'])); |
||
57 | |||
58 | $resourceFields = GridField::create('DataColumns', 'Columns', $resource->Fields(), $columnsConfig); |
||
59 | $resourceFields->addExtraClass('ckan-columns'); |
||
60 | |||
61 | // Configure inline editable checkboxes for the two boolean fields |
||
62 | $before = null; |
||
63 | $editableColumns = $injector->create(GridFieldEditableColumns::class); |
||
64 | foreach ($columnsConfig->getComponents() as $component) { |
||
65 | if ($before !== null) { |
||
66 | $before = $component; |
||
67 | break; |
||
68 | } |
||
69 | if ($component instanceof GridFieldDataColumns) { |
||
70 | $before = false; |
||
71 | $columns = $component->getDisplayFields($resourceFields); |
||
72 | |||
73 | // We only want to change the labels for the GridField view, not the model's edit form |
||
74 | $columns['ShowInSummaryView'] = _t(__CLASS__ . '.IN_RESULTS', 'In Results'); |
||
75 | $columns['ShowInDetailView'] = _t(__CLASS__ . '.IN_DETAIL', 'In Detail'); |
||
76 | |||
77 | $editable = array_flip(['ShowInSummaryView', 'ShowInDetailView']); |
||
78 | $component->setDisplayFields(array_diff_key($columns, $editable)); |
||
79 | // set this way so that title translations are preserved |
||
80 | $editableColumns->setDisplayFields(array_intersect_key($columns, $editable)); |
||
81 | } |
||
82 | } |
||
83 | $columnsConfig->addComponent($editableColumns, $before); |
||
84 | $fields->addFieldToTab('Root.Data', $resourceFields); |
||
85 | |||
86 | $filtersConfig = GridFieldConfig_RecordEditor::create(); |
||
87 | $filtersConfig->removeComponentsByType([ |
||
88 | GridFieldAddExistingAutocompleter::class, |
||
89 | GridFieldAddNewButton::class |
||
90 | ]) |
||
91 | ->addComponents([ |
||
92 | $injector->create(GridFieldAddNewMultiClass::class), |
||
93 | $injector->createWithArgs(GridFieldOrderableRows::class, ['Order']), |
||
94 | ]); |
||
95 | |||
96 | $resourceFilters = GridField::create('DataFilters', 'Filters', $resource->Filters(), $filtersConfig); |
||
97 | |||
98 | $fields->addFieldToTab('Root.Filters', $resourceFilters); |
||
99 | } |
||
100 | }); |
||
101 | |||
102 | return parent::getCMSFields(); |
||
103 | } |
||
116 |
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