| Conditions | 2 |
| Paths | 2 |
| Total Lines | 23 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 17 |
| CRAP Score | 2 |
| 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 | $config->addComponent(new GridFieldOrderableRows('SortOrder')); |
|
| 51 | 1 | $config->removeComponentsByType('GridFieldAddExistingAutocompleter'); |
|
| 52 | 1 | $config->addComponent(new GridFieldAddExistingSearchButton()); |
|
| 53 | 1 | $promos = $this->Promos()->sort('SortOrder'); |
|
|
|
|||
| 54 | 1 | $promoField = GridField::create('Promos', 'Promos', $promos, $config); |
|
| 55 | |||
| 56 | 1 | $fields->addFieldsToTab('Root.Promos', array( |
|
| 57 | 1 | $promoField, |
|
| 58 | 1 | )); |
|
| 59 | 1 | } |
|
| 60 | |||
| 61 | 1 | return $fields; |
|
| 62 | } |
||
| 63 | |||
| 71 | } |
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: