| 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 |
||
| 109 | protected function addLogosAndIcons(FieldList $fields) |
||
| 110 | { |
||
| 111 | $logoTypes = array('jpg', 'jpeg', 'png', 'gif'); |
||
| 112 | $iconTypes = array('ico'); |
||
| 113 | $appleTouchTypes = array('png'); |
||
| 114 | |||
| 115 | $fields->findOrMakeTab( |
||
| 116 | 'Root.LogosIcons', |
||
| 117 | _t(__CLASS__ . '.LogosIconsTab', 'Logos/Icons') |
||
| 118 | ); |
||
| 119 | |||
| 120 | $fields->addFieldToTab( |
||
| 121 | 'Root.LogosIcons', |
||
| 122 | $logoField = Injector::inst()->create( |
||
| 123 | FileHandleField::class, |
||
| 124 | 'Logo', |
||
| 125 | _t(__CLASS__ . '.LogoUploadField', 'Logo, to appear in the top left') |
||
| 126 | ) |
||
| 127 | ); |
||
| 128 | $logoField->getValidator()->setAllowedExtensions($logoTypes); |
||
| 129 | |||
| 130 | $fields->addFieldToTab( |
||
| 131 | 'Root.LogosIcons', |
||
| 132 | $logoRetinaField = Injector::inst()->create( |
||
| 133 | FileHandleField::class, |
||
| 134 | 'LogoRetina', |
||
| 135 | _t( |
||
| 136 | 'CwpConfig.LogoRetinaUploadField', |
||
| 137 | 'High resolution logo, to appear in the top left ' . |
||
| 138 | '(recommended to be twice the height and width of the standard logo)' |
||
| 139 | ) |
||
| 140 | ) |
||
| 141 | ); |
||
| 142 | $logoRetinaField->getValidator()->setAllowedExtensions($logoTypes); |
||
| 143 | |||
| 144 | $fields->addFieldToTab( |
||
| 145 | 'Root.LogosIcons', |
||
| 146 | $footerLogoField = Injector::inst()->create( |
||
| 147 | FileHandleField::class, |
||
| 148 | 'FooterLogo', |
||
| 149 | _t(__CLASS__ . '.FooterLogoField', 'Footer logo, to appear in the footer') |
||
| 150 | ) |
||
| 151 | ); |
||
| 152 | $footerLogoField->getValidator()->setAllowedExtensions($logoTypes); |
||
| 153 | |||
| 154 | $fields->addFieldToTab( |
||
| 155 | 'Root.LogosIcons', |
||
| 156 | $footerLogoRetinaField = Injector::inst()->create( |
||
| 157 | FileHandleField::class, |
||
| 158 | 'FooterLogoRetina', |
||
| 159 | _t( |
||
| 160 | 'CwpConfig.FooterLogoRetinaField', |
||
| 161 | 'High resolution footer logo (recommended twice the height and width of the standard footer logo)' |
||
| 162 | ) |
||
| 163 | ) |
||
| 164 | ); |
||
| 165 | $footerLogoRetinaField->getValidator()->setAllowedExtensions($logoTypes); |
||
| 166 | |||
| 167 | $fields->addFieldToTab( |
||
| 168 | 'Root.LogosIcons', |
||
| 169 | $footerLink = TextField::create( |
||
| 170 | 'FooterLogoLink', |
||
| 171 | _t(__CLASS__ . '.FooterLogoLinkField', 'Footer Logo link') |
||
| 172 | ) |
||
| 173 | ); |
||
| 174 | $footerLink->setRightTitle( |
||
| 175 | _t( |
||
| 176 | 'CwpConfig.FooterLogoLinkDesc', |
||
| 177 | 'Please include the protocol (ie, http:// or https://) unless it is an internal link.' |
||
| 178 | ) |
||
| 179 | ); |
||
| 180 | |||
| 181 | $fields->addFieldToTab( |
||
| 182 | 'Root.LogosIcons', |
||
| 183 | TextField::create( |
||
| 184 | 'FooterLogoDescription', |
||
| 185 | _t(__CLASS__ . '.FooterLogoDescField', 'Footer Logo description') |
||
| 186 | ) |
||
| 187 | ); |
||
| 188 | |||
| 189 | $fields->addFieldToTab( |
||
| 190 | 'Root.LogosIcons', |
||
| 191 | $footerLogoSecondaryField = Injector::inst()->create( |
||
| 192 | FileHandleField::class, |
||
| 193 | 'FooterLogoSecondary', |
||
| 194 | _t(__CLASS__ . '.FooterLogoSecondaryField', 'Secondary Footer Logo, to appear in the footer.') |
||
| 195 | ) |
||
| 196 | ); |
||
| 197 | $footerLogoSecondaryField->getValidator()->setAllowedExtensions($logoTypes); |
||
| 198 | |||
| 199 | $fields->addFieldToTab('Root.LogosIcons', $footerSecondaryLink = TextField::create( |
||
| 200 | 'FooterLogoSecondaryLink', |
||
| 201 | _t(__CLASS__ . '.FooterLogoSecondaryLinkField', 'Secondary Footer Logo link.') |
||
| 202 | )); |
||
| 203 | $footerSecondaryLink->setRightTitle(_t( |
||
| 204 | 'CwpConfig.FooterLogoSecondaryLinkDesc', |
||
| 205 | 'Please include the protocol (ie, http:// or https://) unless it is an internal link.' |
||
| 206 | )); |
||
| 207 | $fields->addFieldToTab('Root.LogosIcons', TextField::create( |
||
| 208 | 'FooterLogoSecondaryDescription', |
||
| 209 | _t(__CLASS__ . '.FooterLogoSecondaryDescField', 'Secondary Footer Logo description') |
||
| 210 | )); |
||
| 211 | |||
| 212 | $fields->addFieldToTab( |
||
| 213 | 'Root.LogosIcons', |
||
| 214 | $favIconField = Injector::inst()->create( |
||
| 215 | FileHandleField::class, |
||
| 216 | 'FavIcon', |
||
| 217 | _t(__CLASS__ . '.FavIconField', 'Favicon, in .ico format, dimensions of 16x16, 32x32, or 48x48') |
||
| 218 | ) |
||
| 219 | ); |
||
| 220 | $favIconField->getValidator()->setAllowedExtensions($iconTypes); |
||
| 221 | |||
| 222 | $fields->addFieldToTab( |
||
| 223 | 'Root.LogosIcons', |
||
| 224 | $atIcon144 = Injector::inst()->create( |
||
| 225 | FileHandleField::class, |
||
| 226 | 'AppleTouchIcon144', |
||
| 227 | _t( |
||
| 228 | 'CwpConfig.AppleIconField144', |
||
| 229 | 'Apple Touch Web Clip and Windows 8 Tile Icon (dimensions of 144x144, PNG format)' |
||
| 230 | ) |
||
| 231 | ) |
||
| 232 | ); |
||
| 233 | $atIcon144->getValidator()->setAllowedExtensions($appleTouchTypes); |
||
| 234 | |||
| 235 | $fields->addFieldToTab( |
||
| 236 | 'Root.LogosIcons', |
||
| 237 | $atIcon114 = Injector::inst()->create( |
||
| 238 | FileHandleField::class, |
||
| 239 | 'AppleTouchIcon114', |
||
| 240 | _t(__CLASS__ . '.AppleIconField114', 'Apple Touch Web Clip Icon (dimensions of 114x114, PNG format)') |
||
| 241 | ) |
||
| 242 | ); |
||
| 243 | $atIcon114->getValidator()->setAllowedExtensions($appleTouchTypes); |
||
| 244 | |||
| 245 | $fields->addFieldToTab( |
||
| 246 | 'Root.LogosIcons', |
||
| 247 | $atIcon72 = Injector::inst()->create( |
||
| 248 | FileHandleField::class, |
||
| 249 | 'AppleTouchIcon72', |
||
| 250 | _t(__CLASS__ . '.AppleIconField72', 'Apple Touch Web Clip Icon (dimensions of 72x72, PNG format)') |
||
| 251 | ) |
||
| 252 | ); |
||
| 253 | $atIcon72->getValidator()->setAllowedExtensions($appleTouchTypes); |
||
| 254 | |||
| 255 | $fields->addFieldToTab( |
||
| 256 | 'Root.LogosIcons', |
||
| 257 | $atIcon57 = Injector::inst()->create( |
||
| 258 | FileHandleField::class, |
||
| 259 | 'AppleTouchIcon57', |
||
| 260 | _t(__CLASS__ . '.AppleIconField57', 'Apple Touch Web Clip Icon (dimensions of 57x57, PNG format)') |
||
| 261 | ) |
||
| 262 | ); |
||
| 263 | $atIcon57->getValidator()->setAllowedExtensions($appleTouchTypes); |
||
| 264 | |||
| 265 | return $this; |
||
| 266 | } |
||
| 302 |