Conditions | 5 |
Paths | 12 |
Total Lines | 100 |
Code Lines | 62 |
Lines | 0 |
Ratio | 0 % |
Changes | 11 | ||
Bugs | 1 | Features | 1 |
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 |
||
76 | public function updateCMSFields(FieldList $fields) |
||
77 | { |
||
78 | $owner = $this->getOwner(); |
||
79 | $name = '[none]'; |
||
80 | if (class_exists((string) $owner->ClassNameLastEdited)) { |
||
81 | $name = Injector::inst()->get($owner->ClassNameLastEdited)->i18n_singular_name(); |
||
82 | } |
||
83 | |||
84 | // page caching |
||
85 | $fields->addFieldsToTab( |
||
86 | 'Root.Caching', |
||
87 | [ |
||
88 | HeaderField::create('FullPageCachingHeader', 'Full Page Caching'), |
||
89 | CheckboxField::create('HasCaching', 'Allow caching of entire pages?') |
||
90 | ->setDescription( |
||
91 | 'You will also need to set up the cache time below for it to be enabled. |
||
92 | You can set a default time below, but you can also set the time for individual pages.' |
||
93 | ), |
||
94 | ] |
||
95 | ); |
||
96 | if ($owner->HasCaching) { |
||
97 | $fields->addFieldsToTab( |
||
98 | 'Root.Caching', |
||
99 | [ |
||
100 | NumericField::create('PublicCacheDurationInSeconds', 'Cache time for ALL pages') |
||
101 | ->setDescription( |
||
102 | 'USE WITH CARE - This will apply caching to ALL pages on the site. |
||
103 | Time is in seconds (e.g. 600 = 10 minutes). |
||
104 | Cache time on individual pages will override this value set here. |
||
105 | The total number of pages on the site with an individual caching time is: ' . Page::get()->filter('PublicCacheDurationInSeconds:GreaterThan', 0)->count() |
||
106 | ), |
||
107 | ] |
||
108 | ); |
||
109 | } |
||
110 | |||
111 | //partial caching |
||
112 | $fields->addFieldsToTab( |
||
113 | 'Root.Caching', |
||
114 | [ |
||
115 | HeaderField::create('PartialCachingHeader', 'Partial Caching'), |
||
116 | CheckboxField::create('HasPartialCaching', 'Allow partial template caching?') |
||
117 | ->setDescription( |
||
118 | 'This should usually be turned on unless you want to make sure no templates are cached in any part at all.' |
||
119 | ), |
||
120 | ] |
||
121 | ); |
||
122 | if ($owner->HasPartialCaching) { |
||
123 | $fields->addFieldsToTab( |
||
124 | 'Root.Caching', |
||
125 | [ |
||
126 | CheckboxField::create('RecordCacheUpdates', 'Keep a record of what is being changed?') |
||
127 | ->setDescription( |
||
128 | 'To work out when the cache is being cleared, |
||
129 | you can keep a record of the last ' . self::MAX_OBJECTS_UPDATED . ' records changed. |
||
130 | Only turn this on temporarily for tuning purposes.' |
||
131 | ), |
||
132 | ] |
||
133 | ); |
||
134 | if ($this->getOwner()->RecordCacheUpdates) { |
||
135 | $fields->addFieldsToTab( |
||
136 | 'Root.Caching', |
||
137 | [ |
||
138 | |||
139 | ReadonlyField::create('CacheKeyLastEditedNice', 'Last database change', $owner->dbObject('CacheKeyLastEdited')->ago()) |
||
140 | ->setDescription( |
||
141 | 'The frontend template cache will be invalidated every time this value changes. |
||
142 | The value changes every time anything is changed in the database.' |
||
143 | ), |
||
144 | ReadonlyField::create('ClassNameLastEditedNice', 'Last record updated', $name) |
||
145 | ->setDescription('The last record to invalidate the cache.'), |
||
146 | |||
147 | GridField::create( |
||
148 | 'ObjectsUpdated', |
||
149 | 'Last ' . self::MAX_OBJECTS_UPDATED . ' records updated', |
||
150 | ObjectsUpdated::get()->limit(self::MAX_OBJECTS_UPDATED), |
||
151 | GridFieldConfig_RecordViewer::create() |
||
152 | ) |
||
153 | ->setDescription( |
||
154 | ' |
||
155 | This is a list of the last ' . self::MAX_OBJECTS_UPDATED . ' records updated. |
||
156 | It is used to track changes to the database. |
||
157 | It includes: ' . ObjectsUpdated::classes_edited() |
||
158 | ), |
||
159 | ] |
||
160 | ); |
||
161 | } |
||
162 | } |
||
163 | // resource caching |
||
164 | $fields->addFieldsToTab( |
||
165 | 'Root.Caching', |
||
166 | [ |
||
167 | HeaderField::create('ResourceCachingHeader', 'Resource Caching'), |
||
168 | CheckboxField::create('HasResourceCaching', 'Allow caching of resources (e.g. images, styles, etc.). ') |
||
169 | ->setDescription( |
||
170 | 'This will add cache control headers to your .htaccess file for images, styles, and scripts. |
||
171 | This will help with performance, but once cached, a cache can not be cleared without changing the file name.' |
||
172 | ), |
||
173 | NumericField::create('ResourceCachingTimeInSeconds', 'Cache time for resources') |
||
174 | ->setDescription( |
||
175 | 'Time is in seconds (e.g. 600 = 10 minutes). |
||
176 | This will be used for all resources on the site (fonts, images, styles, and scripts).' |
||
311 |
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