GridFieldSnippetRow::getHTMLFragments()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 10
rs 10
1
<?php
2
3
namespace ilateral\SilverStripe\ModelAdminPlus;
4
5
use SilverStripe\View\SSViewer;
6
use SilverStripe\View\ArrayData;
7
use SilverStripe\Forms\GridField\GridFieldButtonRow;
8
9
class GridFieldSnippetRow extends GridFieldButtonRow
10
{
11
    public function getHTMLFragments($gridField)
12
    {
13
        $data = ArrayData::create([
14
            "TargetFragmentName" => $this->targetFragment,
15
            "Fragments" => "\$DefineFragment(snippets-{$this->targetFragment})",
16
        ]);
17
18
        $templates = SSViewer::get_templates_by_class($this, '', __CLASS__);
19
        return [
20
            $this->targetFragment => $data->renderWith($templates)
21
        ];
22
    }
23
}