Conditions | 4 |
Paths | 3 |
Total Lines | 67 |
Code Lines | 52 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
109 | public function getCMSFields() |
||
110 | { |
||
111 | $fields = parent::getCMSFields(); |
||
112 | $fields->removeFieldFromTab('Root.Main', 'DataType'); |
||
113 | $fields->removeByName('ContentSourceID'); |
||
114 | $dataObjects = ClassInfo::subclassesFor(DataObject::class); |
||
115 | |||
116 | array_shift($dataObjects); |
||
117 | natcasesort($dataObjects); |
||
118 | |||
119 | $fields->insertBefore('Order', LiteralField::create( |
||
120 | 'ImportIntro', |
||
121 | '' |
||
122 | . '<p class="message notice">Map MIME-Types to Silverstripe Data Types and' |
||
123 | . ' relate them to one or more Import Rules (See below).</p>' |
||
124 | )); |
||
125 | $fields->dataFieldbyName('Order') |
||
126 | ->setDescription('Schema are assigned a higher priority through lower numbers.') |
||
127 | ->setAttribute('style', 'width: 100px'); |
||
128 | |||
129 | $fields->dataFieldByName('AppliesTo') |
||
130 | ->setDescription('A full or partial URI whose content is suited to the Data Type selected below. Supports regular expressions.'); |
||
131 | $fields->addFieldToTab('Root.Main', DropdownField::create('DataType', 'Data Type', $dataObjects)); |
||
132 | $mimes = TextareaField::create('MimeTypes', 'Mime-types') |
||
133 | ->setRows(3) |
||
134 | ->setDescription('Be sure to pick a Mime-type that the above Data Type supports' |
||
135 | . ' e.g. text/html for <strong>SiteTree</strong>,' |
||
136 | . ' image/png, mage/jpeg, image/webp etc for <strong>Image</strong>' |
||
137 | . ' or application/pdf, text/csv etc for <strong>File</strong>.' |
||
138 | . ' Separate multiple Mimes by a newline.'); |
||
139 | $fields->addFieldToTab('Root.Main', $mimes); |
||
140 | $notes = TextareaField::create('Notes', 'Notes') |
||
141 | ->setDescription('Use this field to add any notes about this schema.' |
||
142 | . ' (Purely informational. Data is not used in imports).'); |
||
143 | $fields->addFieldToTab('Root.Main', $notes); |
||
144 | |||
145 | $importRules = $fields->dataFieldByName('ImportRules'); |
||
146 | $fields->removeFieldFromTab('Root', 'ImportRules'); |
||
147 | $fields->dataFieldByName('DataType')->setDescription('' |
||
148 | . 'The Silverstripe content class with which content from the selected' |
||
149 | . ' Mime-Types will be associated.'); |
||
150 | |||
151 | // Don't show for File subclasses, these obviously don't require CSS-based import rules |
||
152 | if ($this->DataType && in_array(File::class, ClassInfo::ancestry($this->DataType))) { |
||
153 | return $fields; |
||
154 | } |
||
155 | |||
156 | if ($importRules) { |
||
157 | $conf = $importRules->getConfig(); |
||
158 | $conf->removeComponentsByType([ |
||
159 | GridFieldAddExistingAutocompleter::class, |
||
160 | GridFieldAddNewButton::class |
||
161 | ]); |
||
162 | $addNewButton = (new GridFieldAddNewButton('before'))->setButtonName("Add Rule"); |
||
163 | $conf->addComponent($addNewButton); |
||
164 | $fields->addFieldToTab('Root.Main', $importRules); |
||
165 | $fields->insertBefore('ImportRules', LiteralField::create( |
||
166 | 'ImportRuleIntro', |
||
167 | '' |
||
168 | . '<p class="message notice">An import rule determines how content located at crawled URLs' |
||
169 | . ' should be imported into a Data Type\'s fields with the use of CSS selectors.' |
||
170 | . ' Where more than one schema exists for the same Data Type, they\'ll be processed in the order of Priority,' |
||
171 | . ' where the first one to match a URI and Mime combination is the one that will be used.<p>' |
||
172 | )); |
||
173 | } |
||
174 | |||
175 | return $fields; |
||
176 | } |
||
313 |
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