AssetFormFactoryExtension::updateFormFields()   A
last analyzed

Complexity

Conditions 5
Paths 6

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 7
rs 9.6111
c 0
b 0
f 0
cc 5
nc 6
nop 4
1
<?php
2
3
namespace Dynamic\Salsify\ORM;
4
5
use SilverStripe\Assets\Image;
6
use SilverStripe\Core\Extension;
7
use SilverStripe\Forms\FieldList;
8
use SilverStripe\Forms\ReadonlyField;
9
10
/**
11
 * Class AssetFormFactoryExtension
12
 * @package Dynamic\Salsify\ORM
13
 *
14
 * @property-read \SilverStripe\AssetAdmin\Forms\FileFormFactory $owner
15
 */
16
class AssetFormFactoryExtension extends Extension
17
{
18
    /**
19
     * @param \SilverStripe\Forms\FieldList $fields
20
     */
21
    public function updateFormFields(FieldList $fields, $controller, $formName, $context)
0 ignored issues
show
Unused Code introduced by
The parameter $formName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

21
    public function updateFormFields(FieldList $fields, $controller, /** @scrutinizer ignore-unused */ $formName, $context)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $controller is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

21
    public function updateFormFields(FieldList $fields, /** @scrutinizer ignore-unused */ $controller, $formName, $context)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
    {
23
        $record = isset($context['Record']) ? $context['Record'] : null;
24
        if ($record && $record->SalsifyID) {
25
            $fields->insertAfter('LastEdited', ReadonlyField::create('SalsifyID', 'Salsify ID'));
26
            if ($record instanceof Image) {
27
                $fields->insertAfter('SalsifyID', ReadonlyField::create('Transformation', 'Salsify Transformation'));
28
            }
29
        }
30
    }
31
}
32