Completed
Pull Request — master (#306)
by Will
02:03
created

FileHistoryFormFactory::getFormFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 1
eloc 8
nc 1
nop 3
1
<?php
2
3
namespace SilverStripe\AssetAdmin\Forms;
4
5
use SilverStripe\Assets\File;
6
use SilverStripe\Control\Controller;
7
use SilverStripe\Forms\FieldList;
8
use SilverStripe\Forms\LiteralField;
9
use SilverStripe\Forms\ReadonlyField;
10
11
class FileHistoryFormFactory extends FileFormFactory
12
{
13
14
    protected function getFormFields(Controller $controller, $name, $context = [])
15
    {
16
        $record = $context['Record'];
17
18
        return new FieldList(
19
            LiteralField::create('Thumbnail', $this->getIconMarkup($record)),
20
            LiteralField::create('FileSpecs', $this->getSpecsMarkup($record)),
21
            ReadonlyField::create("Title", File::singleton()->fieldLabel('Title')),
22
            ReadonlyField::create('Name', File::singleton()->fieldLabel('Filename')),
23
            ReadonlyField::create("Path", _t('AssetTableField.PATH', 'Path'), $this->getPath($record))
24
        );
25
    }
26
27
28
    protected function getFormActions(Controller $controller, $name, $context = [])
29
    {
30
        $record = $context['Record'];
0 ignored issues
show
Unused Code introduced by
$record is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
31
32
        $actions = new FieldList();
33
34
        // Update
35
        $this->invokeWithExtensions('updateFormActions', $actions, $controller, $name, $context);
36
37
        return $actions;
38
    }
39
}
40