| Conditions | 3 |
| Paths | 1 |
| Total Lines | 86 |
| Code Lines | 58 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | 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 |
||
| 85 | public function getCMSFields() |
||
| 86 | { |
||
| 87 | $this->beforeUpdateCMSFields(function (FieldList $fields) { |
||
| 88 | $fields->removeByName([ |
||
| 89 | 'StoreKey', |
||
| 90 | ]); |
||
| 91 | |||
| 92 | $fields->addFieldsToTab('Root.Main', [ |
||
| 93 | ReadonlyField::create('StoreDomain', 'Store Domain', FoxyHelper::config()->get('cart_url')) |
||
| 94 | ->setDescription('This is a unique FoxyCart subdomain for your cart, checkout, and receipt'), |
||
| 95 | CheckboxField::create('CustomSSL', 'Use custom SSL', FoxyHelper::config()->get('custom_ssl')) |
||
| 96 | ->performReadonlyTransformation(), |
||
| 97 | ]); |
||
| 98 | |||
| 99 | if (FoxyHelper::config()->get('secret') != null) { |
||
| 100 | $key = FoxyHelper::config()->get('secret'); |
||
| 101 | $description = 'Your secret key as set in config.yml'; |
||
| 102 | } else { |
||
| 103 | $key = $this->StoreKey; |
||
| 104 | $description = 'Recommended secret key for your Foxy store. Add to your config.yml to implement'; |
||
| 105 | } |
||
| 106 | |||
| 107 | $fields->addFieldToTab( |
||
| 108 | 'Root.Main', |
||
| 109 | ReadonlyField::create('Key', 'Store Key', $key) |
||
| 110 | ->setDescription($description) |
||
| 111 | ); |
||
| 112 | |||
| 113 | if (self::store_name_warning() !== null) { |
||
| 114 | $fields->addFieldToTab('Root.Main', LiteralField::create('StoreSubDomainHeaderWarning', _t( |
||
| 115 | 'ProductPage.StoreSubDomainHeaderWarning', |
||
| 116 | '<p class="message error">Store domain must be entered in the |
||
| 117 | <a href="/admin/foxy/">Foxy settings</a></p>' |
||
| 118 | )), 'StoreDomain'); |
||
| 119 | } |
||
| 120 | |||
| 121 | $fields->addFieldsToTab( |
||
| 122 | 'Root.Options.Settings', |
||
| 123 | [ |
||
| 124 | CheckboxField::create('EnableSidecart', 'Enable Sidecart') |
||
| 125 | ->setDescription('Cart slides in from right side when product added to cart'), |
||
| 126 | ] |
||
| 127 | ); |
||
| 128 | |||
| 129 | $fields->addFieldsToTab( |
||
| 130 | 'Root.Options.VariationTypes', |
||
| 131 | [ |
||
| 132 | LiteralField::create('VariationDescrip', _t( |
||
| 133 | __CLASS__ . '.VariationDescrip', |
||
| 134 | '<p>Product Variation Types allow you to group a set of product variants by type.</p>' |
||
| 135 | )), |
||
| 136 | GridField::create( |
||
| 137 | 'VariationType', |
||
| 138 | _t(__CLASS__ . '.VariationTypeLabel', 'Variation Types'), |
||
| 139 | VariationType::get(), |
||
| 140 | GridFieldConfig_RecordEditor::create() |
||
| 141 | ->addComponents([ |
||
| 142 | new GridFieldOrderableRows('SortOrder') |
||
| 143 | ]) |
||
| 144 | ), |
||
| 145 | ] |
||
| 146 | ); |
||
| 147 | |||
| 148 | $fields->addFieldsToTab('Root.Categories', [ |
||
| 149 | LiteralField::create('CategoryDescrip', _t( |
||
| 150 | __CLASS__ . '.CategoryDescrip', |
||
| 151 | '<p>FoxyCart Categories offer a way to give products additional behaviors that cannot be |
||
| 152 | accomplished by product options alone, including category specific coupon codes, |
||
| 153 | shipping and handling fees, and email receipts. |
||
| 154 | <a href="https://wiki.foxycart.com/v/2.0/categories" target="_blank"> |
||
| 155 | Learn More |
||
| 156 | </a></p> |
||
| 157 | <p>Categories you\'ve created in FoxyStripe must also be created in your |
||
| 158 | <a href="https://admin.foxycart.com/admin.php?ThisAction=ManageProductCategories" |
||
| 159 | target="_blank">FoxyCart Categories</a> admin panel.</p>' |
||
| 160 | )), |
||
| 161 | GridField::create( |
||
| 162 | 'FoxyCategory', |
||
| 163 | _t(__CLASS__ . '.FoxyCategory', 'FoxyCart Categories'), |
||
| 164 | FoxyCategory::get(), |
||
| 165 | GridFieldConfig_RecordEditor::create() |
||
| 166 | ), |
||
| 167 | ]); |
||
| 168 | }); |
||
| 169 | |||
| 170 | return parent::getCMSFields(); |
||
| 171 | } |
||
| 340 |