Completed
Pull Request — master (#306)
by Damian
02:01
created

FileHistoryFormFactory::getFormActions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
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\FormFactory;
9
use SilverStripe\Forms\LiteralField;
10
use SilverStripe\Forms\ReadonlyField;
11
12
class FileHistoryFormFactory extends FileFormFactory
13
{
14
    public function getForm(Controller $controller, $name = FormFactory::DEFAULT_NAME, $context = [])
15
    {
16
        $form = parent::getForm($controller, $name, $context);
17
        $form->makeReadonly();
18
        return $form;
19
    }
20
21
    protected function getFormFields(Controller $controller, $name, $context = [])
22
    {
23
        $record = $context['Record'];
24
25
        $fields = new FieldList(
26
            LiteralField::create('Thumbnail', $this->getIconMarkup($record)),
27
            LiteralField::create('FileSpecs', $this->getSpecsMarkup($record)),
28
            ReadonlyField::create("Title", File::singleton()->fieldLabel('Title')),
29
            ReadonlyField::create('Name', File::singleton()->fieldLabel('Filename')),
30
            ReadonlyField::create("Path", _t('AssetTableField.PATH', 'Path'), $this->getPath($record))
31
        );
32
33
        $this->invokeWithExtensions('updateFormFields', $fields, $controller, $name, $context);
34
35
        return $fields;
36
    }
37
38
39
    protected function getFormActions(Controller $controller, $name, $context = [])
40
    {
41
        $actions = new FieldList();
42
        // Update
43
        $this->invokeWithExtensions('updateFormActions', $actions, $controller, $name, $context);
44
45
        return $actions;
46
    }
47
}
48