Passed
Pull Request — master (#5)
by Robbie
02:43
created

HistoryViewerField::getSourceRecord()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 2
eloc 1
nc 2
nop 0
1
<?php
2
3
namespace SilverStripe\VersionedAdmin\Forms;
4
5
use SilverStripe\Forms\FormField;
6
use SilverStripe\ORM\DataObject;
7
use SilverStripe\View\Requirements;
8
9
class HistoryViewerField extends FormField
10
{
11
    /**
12
     * Default to using the SiteTree component
13
     *
14
     * @var string
15
     */
16
    protected $schemaComponent = 'PageHistoryViewer';
17
18
    public function __construct($name, $title = null, $value = null)
19
    {
20
        Requirements::javascript('silverstripe/versioned-admin:client/dist/js/bundle.js');
21
        Requirements::css('silverstripe/versioned-admin:client/dist/styles/bundle.css');
22
23
        parent::__construct($name, $title, $value);
24
    }
25
26
    /**
27
     * Get the source record to view history for
28
     *
29
     * @return DataObject|null
30
     */
31
    public function getSourceRecord()
32
    {
33
        return $this->getForm() ? $this->getForm()->getRecord() : null;
34
    }
35
}
36