Completed
Push — master ( 3da775...1e6bd3 )
by Robbie
9s
created

GridFieldHtmlFragment::getHTMLFragments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace BringYourOwnIdeas\Maintenance\Forms;
4
5
use SilverStripe\Forms\GridField\GridField;
6
use SilverStripe\Forms\GridField\GridField_HTMLProvider;
7
8
/**
9
 * Facilitates adding arbitrary HTML to grid fields
10
 *
11
 * @package forms
12
 * @subpackage fields-gridfield
13
 */
14
15
class GridFieldHtmlFragment implements GridField_HTMLProvider
16
{
17
    /**
18
     * Fragment to write the html fragment to.
19
     * @var string
20
     */
21
    protected $targetFragment;
22
23
    /**
24
     * An HTML fragment to render
25
     * @var string
26
     */
27
    protected $htmlFragment;
28
29
    /**
30
     * @param string $targetFragment Fragment to write the html fragment to.
31
     * @param string $htmlFragment An HTML fragment to render
32
     */
33
    public function __construct($targetFragment, $htmlFragment)
34
    {
35
        $this->targetFragment = $targetFragment;
36
        $this->htmlFragment = $htmlFragment;
37
    }
38
39
    /**
40
     * @param GridField $gridField
41
     * @return array
42
     */
43
    public function getHTMLFragments($gridField)
44
    {
45
        return [$this->targetFragment => $this->htmlFragment];
46
    }
47
}
48