NutriHolderProductDataExtension::updateCMSFields()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 1
1
<?php
2
3
class NutriHolderProductDataExtension extends DataExtension
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    private static $has_one = array(
0 ignored issues
show
Unused Code introduced by
The property $has_one is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
6
        'NutriHolder' => 'NutriHolder'
7
    );
8
9
    /**
10
     * Update Fields
11
     * @return FieldList
0 ignored issues
show
Documentation introduced by
Should the return type not be FieldList|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
12
     */
13
    public function updateCMSFields(FieldList $fields)
14
    {
15
        $fields->removeByName('NutriHolderID');
16
        if ($this->owner->NutriHolder()->exists()) {
17
            $fields->addFieldsToTab(
18
                'Root.Nutrition',
19
                array(
20
                    HasOneButtonField::create('NutriHolder', 'Nutritional Info', $this->owner),
21
                    HeaderField::create('SelectNutriHolderHeader', 'Select existing Nutritional Information Profile'),
22
                    DropDownField::create('NutriHolderID', 'Nutritional Info', array("" => "-- please select --") + NutriHolder::get()->map()->toArray())
23
                        ->setRightTitle('Select an existing Nutritional Information Profile'),
24
                )
25
            );
26
        }
27
    }
28
}
29