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 1
    public function getRestoreAction($gridField, $record, $columnName)
17
    {
18
        // Only show the action if the file exists
19 1
        if ($record instanceof File && $record->exists()) {
20 1
            return parent::getRestoreAction($gridField, $record, $columnName);
21
        }
22 1
        return null;
23
    }
24
}

Read our documentation on viewing source code .

Loading