| Conditions | 4 |
| Paths | 5 |
| Total Lines | 27 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 19 |
| CRAP Score | 4.0138 |
| Changes | 0 | ||
| 1 | <?php |
||
| 40 | 1 | public function getCMSFields() |
|
| 41 | { |
||
| 42 | 1 | $fields = parent::getCMSFields(); |
|
| 43 | |||
| 44 | 1 | $fields->removeByName(array( |
|
| 45 | 1 | 'Promos', |
|
| 46 | 1 | )); |
|
| 47 | |||
| 48 | 1 | if ($this->ID) { |
|
| 49 | 1 | $config = GridFieldConfig_RelationEditor::create(); |
|
| 50 | 1 | if (class_exists('GridFieldSortableRows')) { |
|
| 51 | $config->addComponent(new GridFieldSortableRows('SortOrder')); |
||
| 52 | } |
||
| 53 | 1 | if (class_exists('GridFieldAddExistingSearchButton')) { |
|
| 54 | 1 | $config->removeComponentsByType('GridFieldAddExistingAutocompleter'); |
|
| 55 | 1 | $config->addComponent(new GridFieldAddExistingSearchButton()); |
|
| 56 | 1 | } |
|
| 57 | 1 | $promos = $this->Promos()->sort('SortOrder'); |
|
|
|
|||
| 58 | 1 | $promoField = GridField::create('Promos', 'Promos', $promos, $config); |
|
| 59 | |||
| 60 | 1 | $fields->addFieldsToTab('Root.Main', array( |
|
| 61 | 1 | $promoField, |
|
| 62 | 1 | )); |
|
| 63 | 1 | } |
|
| 64 | |||
| 65 | 1 | return $fields; |
|
| 66 | } |
||
| 67 | |||
| 75 | } |
If you implement
__calland you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__callis implemented by a parent class and only the child class knows which methods exist: