Passed
Push — master ( 3d7f15...de16b5 )
by Thomas
02:45
created

AbstractTabulatorTool::isAdmini()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace LeKoala\Tabulator;
4
5
use SilverStripe\Control\RequestHandler;
6
7
/**
8
 * This is the base class for tools (see TabulatorAddNewButton for sample usage)
9
 */
10
class AbstractTabulatorTool extends RequestHandler
11
{
12
    protected TabulatorGrid $tabulatorGrid;
13
14
    protected string $name;
15
16
    protected string $link = '';
17
18
    /**
19
     * Get the value of tabulatorGrid
20
     */
21
    public function getTabulatorGrid(): TabulatorGrid
22
    {
23
        return $this->tabulatorGrid;
24
    }
25
26
    /**
27
     * Set the value of tabulatorGrid
28
     */
29
    public function setTabulatorGrid(TabulatorGrid $tabulatorGrid): self
30
    {
31
        $this->tabulatorGrid = $tabulatorGrid;
32
        return $this;
33
    }
34
35
    public function getName(): string
36
    {
37
        return $this->name;
38
    }
39
40
    public function setName($name): self
41
    {
42
        $this->name = $name;
43
        return $this;
44
    }
45
46
    public function Link($action = null): string
47
    {
48
        if (!$this->link) {
49
            return $this->tabulatorGrid->Link('tool/' . $this->name);
50
        }
51
        return $this->link;
52
    }
53
54
    public function isAdmini()
55
    {
56
        return $this->tabulatorGrid->getCompatLayer() instanceof AdminiCompat;
57
    }
58
}
59