Passed
Push — master ( bb21bb...10576c )
by Thomas
23:04 queued 11:25
created

AbstractTabulatorTool::setButtonName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 1
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
 * For tools handling requests, implement index method (see TabulatorExportButton)
10
 */
11
class AbstractTabulatorTool extends RequestHandler
12
{
13
    protected TabulatorGrid $tabulatorGrid;
14
15
    protected string $buttonName = '';
16
    protected string $name = '';
17
    protected string $link = '';
18
    protected bool $newWindow = false;
19
20
    /**
21
     * Get the value of tabulatorGrid
22
     */
23
    public function getTabulatorGrid(): TabulatorGrid
24
    {
25
        return $this->tabulatorGrid;
26
    }
27
28
    /**
29
     * Set the value of tabulatorGrid
30
     */
31
    public function setTabulatorGrid(TabulatorGrid $tabulatorGrid): self
32
    {
33
        $this->tabulatorGrid = $tabulatorGrid;
34
        return $this;
35
    }
36
37
    public function getName(): string
38
    {
39
        return $this->name;
40
    }
41
42
    public function setName($name): self
43
    {
44
        // Don't overwrite given name with empty val
45
        if ($name) {
46
            $this->name = $name;
47
        }
48
        return $this;
49
    }
50
51
    public function Link($action = null)
52
    {
53
        if (!$this->link) {
54
            return $this->tabulatorGrid->Link('tool/' . $this->name);
55
        }
56
        return $this->link;
57
    }
58
59
    public function isAdmini()
60
    {
61
        return $this->tabulatorGrid->getCompatLayer() instanceof AdminiCompat;
62
    }
63
64
    /**
65
     * Get the value of newWindow
66
     */
67
    public function getNewWindow(): bool
68
    {
69
        return $this->newWindow;
70
    }
71
72
    /**
73
     * Set the value of newWindow
74
     *
75
     * @param bool $newWindow
76
     */
77
    public function setNewWindow($newWindow): self
78
    {
79
        $this->newWindow = $newWindow;
80
        return $this;
81
    }
82
83
    /**
84
     * Get the value of buttonName
85
     */
86
    public function getButtonName(): string
87
    {
88
        return $this->buttonName;
89
    }
90
91
    /**
92
     * Set the value of buttonName
93
     *
94
     * @param string $buttonName
95
     */
96
    public function setButtonName($buttonName): self
97
    {
98
        $this->buttonName = $buttonName;
99
        return $this;
100
    }
101
}
102