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

GridFieldHtmlFragment   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getHTMLFragments() 0 3 1
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