Conditions | 3 |
Paths | 2 |
Total Lines | 20 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
15 | 1 | public function getCMSFields() |
|
16 | { |
||
17 | 1 | $fields = parent::getCMSFields(); |
|
18 | |||
19 | 1 | if ($relations = ClassInfo::subclassesFor('ProductDoc')) { |
|
20 | 1 | unset($relations['ProductDoc']); |
|
21 | 1 | foreach ($relations as $key => $value) { |
|
22 | 1 | $relations[$key] = singleton($value)->i18n_singular_name(); |
|
23 | 1 | } |
|
24 | |||
25 | 1 | $fields->addFieldToTab( |
|
26 | 1 | 'Root.Main', |
|
27 | 1 | DropdownField::create('ManagedClass', 'Files to display', $relations) |
|
28 | 1 | ->setEmptyString(''), |
|
29 | 'Content' |
||
30 | 1 | ); |
|
31 | 1 | } |
|
32 | |||
33 | 1 | return $fields; |
|
34 | } |
||
35 | } |
||
40 | } |
Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.