Conditions | 4 |
Paths | 5 |
Total Lines | 23 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 4.0218 |
Changes | 0 |
1 | <?php |
||
40 | 1 | public function getCMSFields() |
|
41 | { |
||
42 | 1 | $fields = parent::getCMSFields(); |
|
43 | |||
44 | 1 | if ($this->ID) { |
|
45 | 1 | $config = GridFieldConfig_RelationEditor::create(); |
|
46 | 1 | if (class_exists('GridFieldSortableRows')) { |
|
47 | $config->addComponent(new GridFieldSortableRows('SortOrder')); |
||
48 | } |
||
49 | 1 | if (class_exists('GridFieldAddExistingSearchButton')) { |
|
50 | 1 | $config->removeComponentsByType('GridFieldAddExistingAutocompleter'); |
|
51 | 1 | $config->addComponent(new GridFieldAddExistingSearchButton()); |
|
52 | 1 | } |
|
53 | 1 | $promos = $this->Promos()->sort('SortOrder'); |
|
|
|||
54 | 1 | $promoField = GridField::create('Promos', 'Promos', $promos, $config); |
|
55 | |||
56 | 1 | $fields->addFieldsToTab('Root.Main', array( |
|
57 | 1 | $promoField, |
|
58 | 1 | )); |
|
59 | 1 | } |
|
60 | |||
61 | 1 | return $fields; |
|
62 | } |
||
63 | |||
71 | } |
If you implement
__call
and 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
__call
is implemented by a parent class and only the child class knows which methods exist: