makeReadonOnlyForCMSFieldsAll()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Sunnysideup\CMSNiceties\Traits;
4
5
use SilverStripe\Forms\FieldList;
6
7
// use SilverStripe\Forms\GridField\GridFieldArchiveAction;
8
9
trait CMSNicetiesTraitForReadOnly
10
{
11
    protected function makeReadonOnlyForCMSFields(FieldList $fields, string $fieldName)
12
    {
13
        $field = $fields->dataFieldByName($fieldName);
14
        if ($field) {
15
            $fields->replaceField(
16
                $fieldName,
17
                $field->performReadonlyTransformation()
18
            );
19
        }
20
    }
21
22
    protected function makeReadonOnlyForCMSFieldsAll(FieldList $fields, array $arrayOfFields)
23
    {
24
        foreach ($arrayOfFields as $fieldName) {
25
            $this->makeReadonOnlyForCMSFields($fields, $fieldName);
26
        }
27
    }
28
}
29