| 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 |
||
| 70 | protected function addLogosAndIcons(FieldList $fields) |
||
| 71 | { |
||
| 72 | $logoTypes = array('jpg', 'jpeg', 'png', 'gif'); |
||
| 73 | $iconTypes = array('ico'); |
||
| 74 | $appleTouchTypes = array('png'); |
||
| 75 | |||
| 76 | $fields->findOrMakeTab( |
||
| 77 | 'Root.LogosIcons', |
||
| 78 | _t(__CLASS__ . '.LogosIconsTab', 'Logos/Icons') |
||
| 79 | ); |
||
| 80 | |||
| 81 | $fields->addFieldToTab( |
||
| 82 | 'Root.LogosIcons', |
||
| 83 | $logoField = Injector::inst()->create( |
||
| 84 | FileHandleField::class, |
||
| 85 | 'Logo', |
||
| 86 | _t(__CLASS__ . '.LogoUploadField', 'Logo, to appear in the top left') |
||
| 87 | ) |
||
| 88 | ); |
||
| 89 | $logoField->getValidator()->setAllowedExtensions($logoTypes); |
||
| 90 | |||
| 91 | $fields->addFieldToTab( |
||
| 92 | 'Root.LogosIcons', |
||
| 93 | $logoRetinaField = Injector::inst()->create( |
||
| 94 | FileHandleField::class, |
||
| 95 | 'LogoRetina', |
||
| 96 | _t( |
||
| 97 | 'CwpConfig.LogoRetinaUploadField', |
||
| 98 | 'High resolution logo, to appear in the top left ' . |
||
| 99 | '(recommended to be twice the height and width of the standard logo)' |
||
| 100 | ) |
||
| 101 | ) |
||
| 102 | ); |
||
| 103 | $logoRetinaField->getValidator()->setAllowedExtensions($logoTypes); |
||
| 104 | |||
| 105 | $fields->addFieldToTab( |
||
| 106 | 'Root.LogosIcons', |
||
| 107 | $footerLogoField = Injector::inst()->create( |
||
| 108 | FileHandleField::class, |
||
| 109 | 'FooterLogo', |
||
| 110 | _t(__CLASS__ . '.FooterLogoField', 'Footer logo, to appear in the footer') |
||
| 111 | ) |
||
| 112 | ); |
||
| 113 | $footerLogoField->getValidator()->setAllowedExtensions($logoTypes); |
||
| 114 | |||
| 115 | $fields->addFieldToTab( |
||
| 116 | 'Root.LogosIcons', |
||
| 117 | $footerLogoRetinaField = Injector::inst()->create( |
||
| 118 | FileHandleField::class, |
||
| 119 | 'FooterLogoRetina', |
||
| 120 | _t( |
||
| 121 | 'CwpConfig.FooterLogoRetinaField', |
||
| 122 | 'High resolution footer logo (recommended twice the height and width of the standard footer logo)' |
||
| 123 | ) |
||
| 124 | ) |
||
| 125 | ); |
||
| 126 | $footerLogoRetinaField->getValidator()->setAllowedExtensions($logoTypes); |
||
| 127 | |||
| 128 | $fields->addFieldToTab( |
||
| 129 | 'Root.LogosIcons', |
||
| 130 | $footerLink = TextField::create( |
||
| 131 | 'FooterLogoLink', |
||
| 132 | _t(__CLASS__ . '.FooterLogoLinkField', 'Footer Logo link') |
||
| 133 | ) |
||
| 134 | ); |
||
| 135 | $footerLink->setRightTitle( |
||
| 136 | _t( |
||
| 137 | 'CwpConfig.FooterLogoLinkDesc', |
||
| 138 | 'Please include the protocol (ie, http:// or https://) unless it is an internal link.' |
||
| 139 | ) |
||
| 140 | ); |
||
| 141 | |||
| 142 | $fields->addFieldToTab( |
||
| 143 | 'Root.LogosIcons', |
||
| 144 | TextField::create( |
||
| 145 | 'FooterLogoDescription', |
||
| 146 | _t(__CLASS__ . '.FooterLogoDescField', 'Footer Logo description') |
||
| 147 | ) |
||
| 148 | ); |
||
| 149 | |||
| 150 | $fields->addFieldToTab( |
||
| 151 | 'Root.LogosIcons', |
||
| 152 | $footerLogoSecondaryField = Injector::inst()->create( |
||
| 153 | FileHandleField::class, |
||
| 154 | 'FooterLogoSecondary', |
||
| 155 | _t(__CLASS__ . '.FooterLogoSecondaryField', 'Secondary Footer Logo, to appear in the footer.') |
||
| 156 | ) |
||
| 157 | ); |
||
| 158 | $footerLogoSecondaryField->getValidator()->setAllowedExtensions($logoTypes); |
||
| 159 | |||
| 160 | $fields->addFieldToTab('Root.LogosIcons', $footerSecondaryLink = TextField::create( |
||
| 161 | 'FooterLogoSecondaryLink', |
||
| 162 | _t(__CLASS__ . '.FooterLogoSecondaryLinkField', 'Secondary Footer Logo link.') |
||
| 163 | )); |
||
| 164 | $footerSecondaryLink->setRightTitle(_t( |
||
| 165 | 'CwpConfig.FooterLogoSecondaryLinkDesc', |
||
| 166 | 'Please include the protocol (ie, http:// or https://) unless it is an internal link.' |
||
| 167 | )); |
||
| 168 | $fields->addFieldToTab('Root.LogosIcons', TextField::create( |
||
| 169 | 'FooterLogoSecondaryDescription', |
||
| 170 | _t(__CLASS__ . '.FooterLogoSecondaryDescField', 'Secondary Footer Logo description') |
||
| 171 | )); |
||
| 172 | |||
| 173 | $fields->addFieldToTab( |
||
| 174 | 'Root.LogosIcons', |
||
| 175 | $favIconField = Injector::inst()->create( |
||
| 176 | FileHandleField::class, |
||
| 177 | 'FavIcon', |
||
| 178 | _t(__CLASS__ . '.FavIconField', 'Favicon, in .ico format, dimensions of 16x16, 32x32, or 48x48') |
||
| 179 | ) |
||
| 180 | ); |
||
| 181 | $favIconField->getValidator()->setAllowedExtensions($iconTypes); |
||
| 182 | |||
| 183 | $fields->addFieldToTab( |
||
| 184 | 'Root.LogosIcons', |
||
| 185 | $atIcon144 = Injector::inst()->create( |
||
| 186 | FileHandleField::class, |
||
| 187 | 'AppleTouchIcon144', |
||
| 188 | _t( |
||
| 189 | 'CwpConfig.AppleIconField144', |
||
| 190 | 'Apple Touch Web Clip and Windows 8 Tile Icon (dimensions of 144x144, PNG format)' |
||
| 191 | ) |
||
| 192 | ) |
||
| 193 | ); |
||
| 194 | $atIcon144->getValidator()->setAllowedExtensions($appleTouchTypes); |
||
| 195 | |||
| 196 | $fields->addFieldToTab( |
||
| 197 | 'Root.LogosIcons', |
||
| 198 | $atIcon114 = Injector::inst()->create( |
||
| 199 | FileHandleField::class, |
||
| 200 | 'AppleTouchIcon114', |
||
| 201 | _t(__CLASS__ . '.AppleIconField114', 'Apple Touch Web Clip Icon (dimensions of 114x114, PNG format)') |
||
| 202 | ) |
||
| 203 | ); |
||
| 204 | $atIcon114->getValidator()->setAllowedExtensions($appleTouchTypes); |
||
| 205 | |||
| 206 | $fields->addFieldToTab( |
||
| 207 | 'Root.LogosIcons', |
||
| 208 | $atIcon72 = Injector::inst()->create( |
||
| 209 | FileHandleField::class, |
||
| 210 | 'AppleTouchIcon72', |
||
| 211 | _t(__CLASS__ . '.AppleIconField72', 'Apple Touch Web Clip Icon (dimensions of 72x72, PNG format)') |
||
| 212 | ) |
||
| 213 | ); |
||
| 214 | $atIcon72->getValidator()->setAllowedExtensions($appleTouchTypes); |
||
| 215 | |||
| 216 | $fields->addFieldToTab( |
||
| 217 | 'Root.LogosIcons', |
||
| 218 | $atIcon57 = Injector::inst()->create( |
||
| 219 | FileHandleField::class, |
||
| 220 | 'AppleTouchIcon57', |
||
| 221 | _t(__CLASS__ . '.AppleIconField57', 'Apple Touch Web Clip Icon (dimensions of 57x57, PNG format)') |
||
| 222 | ) |
||
| 223 | ); |
||
| 224 | $atIcon57->getValidator()->setAllowedExtensions($appleTouchTypes); |
||
| 225 | |||
| 226 | return $this; |
||
| 227 | } |
||
| 274 |