| Conditions | 1 |
| Paths | 1 |
| Total Lines | 157 |
| Code Lines | 107 |
| 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 |
||
| 201 | protected function addLogosAndIcons(FieldList $fields) |
||
| 202 | { |
||
| 203 | $logoTypes = array('jpg', 'jpeg', 'png', 'gif'); |
||
| 204 | $iconTypes = array('ico'); |
||
| 205 | $appleTouchTypes = array('png'); |
||
| 206 | |||
| 207 | $fields->findOrMakeTab( |
||
| 208 | 'Root.LogosIcons', |
||
| 209 | _t(__CLASS__ . '.LogosIconsTab', 'Logos/Icons') |
||
| 210 | ); |
||
| 211 | |||
| 212 | $fields->addFieldToTab( |
||
| 213 | 'Root.LogosIcons', |
||
| 214 | $logoField = Injector::inst()->create( |
||
| 215 | FileHandleField::class, |
||
| 216 | 'Logo', |
||
| 217 | _t(__CLASS__ . '.LogoUploadField', 'Logo, to appear in the top left') |
||
| 218 | ) |
||
| 219 | ); |
||
| 220 | $logoField->getValidator()->setAllowedExtensions($logoTypes); |
||
| 221 | |||
| 222 | $fields->addFieldToTab( |
||
| 223 | 'Root.LogosIcons', |
||
| 224 | $logoRetinaField = Injector::inst()->create( |
||
| 225 | FileHandleField::class, |
||
| 226 | 'LogoRetina', |
||
| 227 | _t( |
||
| 228 | 'CwpConfig.LogoRetinaUploadField', |
||
| 229 | 'High resolution logo, to appear in the top left ' . |
||
| 230 | '(recommended to be twice the height and width of the standard logo)' |
||
| 231 | ) |
||
| 232 | ) |
||
| 233 | ); |
||
| 234 | $logoRetinaField->getValidator()->setAllowedExtensions($logoTypes); |
||
| 235 | |||
| 236 | $fields->addFieldToTab( |
||
| 237 | 'Root.LogosIcons', |
||
| 238 | $footerLogoField = Injector::inst()->create( |
||
| 239 | FileHandleField::class, |
||
| 240 | 'FooterLogo', |
||
| 241 | _t(__CLASS__ . '.FooterLogoField', 'Footer logo, to appear in the footer') |
||
| 242 | ) |
||
| 243 | ); |
||
| 244 | $footerLogoField->getValidator()->setAllowedExtensions($logoTypes); |
||
| 245 | |||
| 246 | $fields->addFieldToTab( |
||
| 247 | 'Root.LogosIcons', |
||
| 248 | $footerLogoRetinaField = Injector::inst()->create( |
||
| 249 | FileHandleField::class, |
||
| 250 | 'FooterLogoRetina', |
||
| 251 | _t( |
||
| 252 | 'CwpConfig.FooterLogoRetinaField', |
||
| 253 | 'High resolution footer logo (recommended twice the height and width of the standard footer logo)' |
||
| 254 | ) |
||
| 255 | ) |
||
| 256 | ); |
||
| 257 | $footerLogoRetinaField->getValidator()->setAllowedExtensions($logoTypes); |
||
| 258 | |||
| 259 | $fields->addFieldToTab( |
||
| 260 | 'Root.LogosIcons', |
||
| 261 | $footerLink = TextField::create( |
||
| 262 | 'FooterLogoLink', |
||
| 263 | _t(__CLASS__ . '.FooterLogoLinkField', 'Footer Logo link') |
||
| 264 | ) |
||
| 265 | ); |
||
| 266 | $footerLink->setRightTitle( |
||
| 267 | _t( |
||
| 268 | 'CwpConfig.FooterLogoLinkDesc', |
||
| 269 | 'Please include the protocol (ie, http:// or https://) unless it is an internal link.' |
||
| 270 | ) |
||
| 271 | ); |
||
| 272 | |||
| 273 | $fields->addFieldToTab( |
||
| 274 | 'Root.LogosIcons', |
||
| 275 | TextField::create( |
||
| 276 | 'FooterLogoDescription', |
||
| 277 | _t(__CLASS__ . '.FooterLogoDescField', 'Footer Logo description') |
||
| 278 | ) |
||
| 279 | ); |
||
| 280 | |||
| 281 | $fields->addFieldToTab( |
||
| 282 | 'Root.LogosIcons', |
||
| 283 | $footerLogoSecondaryField = Injector::inst()->create( |
||
| 284 | FileHandleField::class, |
||
| 285 | 'FooterLogoSecondary', |
||
| 286 | _t(__CLASS__ . '.FooterLogoSecondaryField', 'Secondary Footer Logo, to appear in the footer.') |
||
| 287 | ) |
||
| 288 | ); |
||
| 289 | $footerLogoSecondaryField->getValidator()->setAllowedExtensions($logoTypes); |
||
| 290 | |||
| 291 | $fields->addFieldToTab('Root.LogosIcons', $footerSecondaryLink = TextField::create( |
||
| 292 | 'FooterLogoSecondaryLink', |
||
| 293 | _t(__CLASS__ . '.FooterLogoSecondaryLinkField', 'Secondary Footer Logo link.') |
||
| 294 | )); |
||
| 295 | $footerSecondaryLink->setRightTitle(_t( |
||
| 296 | 'CwpConfig.FooterLogoSecondaryLinkDesc', |
||
| 297 | 'Please include the protocol (ie, http:// or https://) unless it is an internal link.' |
||
| 298 | )); |
||
| 299 | $fields->addFieldToTab('Root.LogosIcons', TextField::create( |
||
| 300 | 'FooterLogoSecondaryDescription', |
||
| 301 | _t(__CLASS__ . '.FooterLogoSecondaryDescField', 'Secondary Footer Logo description') |
||
| 302 | )); |
||
| 303 | |||
| 304 | $fields->addFieldToTab( |
||
| 305 | 'Root.LogosIcons', |
||
| 306 | $favIconField = Injector::inst()->create( |
||
| 307 | FileHandleField::class, |
||
| 308 | 'FavIcon', |
||
| 309 | _t(__CLASS__ . '.FavIconField', 'Favicon, in .ico format, dimensions of 16x16, 32x32, or 48x48') |
||
| 310 | ) |
||
| 311 | ); |
||
| 312 | $favIconField->getValidator()->setAllowedExtensions($iconTypes); |
||
| 313 | |||
| 314 | $fields->addFieldToTab( |
||
| 315 | 'Root.LogosIcons', |
||
| 316 | $atIcon144 = Injector::inst()->create( |
||
| 317 | FileHandleField::class, |
||
| 318 | 'AppleTouchIcon144', |
||
| 319 | _t( |
||
| 320 | 'CwpConfig.AppleIconField144', |
||
| 321 | 'Apple Touch Web Clip and Windows 8 Tile Icon (dimensions of 144x144, PNG format)' |
||
| 322 | ) |
||
| 323 | ) |
||
| 324 | ); |
||
| 325 | $atIcon144->getValidator()->setAllowedExtensions($appleTouchTypes); |
||
| 326 | |||
| 327 | $fields->addFieldToTab( |
||
| 328 | 'Root.LogosIcons', |
||
| 329 | $atIcon114 = Injector::inst()->create( |
||
| 330 | FileHandleField::class, |
||
| 331 | 'AppleTouchIcon114', |
||
| 332 | _t(__CLASS__ . '.AppleIconField114', 'Apple Touch Web Clip Icon (dimensions of 114x114, PNG format)') |
||
| 333 | ) |
||
| 334 | ); |
||
| 335 | $atIcon114->getValidator()->setAllowedExtensions($appleTouchTypes); |
||
| 336 | |||
| 337 | $fields->addFieldToTab( |
||
| 338 | 'Root.LogosIcons', |
||
| 339 | $atIcon72 = Injector::inst()->create( |
||
| 340 | FileHandleField::class, |
||
| 341 | 'AppleTouchIcon72', |
||
| 342 | _t(__CLASS__ . '.AppleIconField72', 'Apple Touch Web Clip Icon (dimensions of 72x72, PNG format)') |
||
| 343 | ) |
||
| 344 | ); |
||
| 345 | $atIcon72->getValidator()->setAllowedExtensions($appleTouchTypes); |
||
| 346 | |||
| 347 | $fields->addFieldToTab( |
||
| 348 | 'Root.LogosIcons', |
||
| 349 | $atIcon57 = Injector::inst()->create( |
||
| 350 | FileHandleField::class, |
||
| 351 | 'AppleTouchIcon57', |
||
| 352 | _t(__CLASS__ . '.AppleIconField57', 'Apple Touch Web Clip Icon (dimensions of 57x57, PNG format)') |
||
| 353 | ) |
||
| 354 | ); |
||
| 355 | $atIcon57->getValidator()->setAllowedExtensions($appleTouchTypes); |
||
| 356 | |||
| 357 | return $this; |
||
| 358 | } |
||
| 560 |