GridFieldFileRestoreAction   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 4
c 1
b 1
f 0
dl 0
loc 12
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getRestoreAction() 0 7 3
1
<?php
2
3
namespace SilverStripe\VersionedAdmin\Forms\GridField;
4
5
use SilverStripe\Assets\File;
6
use SilverStripe\Versioned\GridFieldRestoreAction;
7
8
/**
9
 * Extension of GridFieldRestoreAction to only show action if there is a valid file
10
 */
11
class GridFieldFileRestoreAction extends GridFieldRestoreAction
12
{
13
    /**
14
     * @inheritdoc
15
     */
16
    public function getRestoreAction($gridField, $record, $columnName)
17
    {
18
        // Only show the action if the file exists
19
        if ($record instanceof File && $record->exists()) {
20
            return parent::getRestoreAction($gridField, $record, $columnName);
21
        }
22
        return null;
23
    }
24
}
25