Passed
Push — master ( 493c3e...a4042e )
by Thomas
03:08
created

AbstractTabulatorTool::setNewWindow()   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 $name = '';
16
    protected string $link = '';
17
    protected bool $newWindow = false;
18
19
    /**
20
     * Get the value of tabulatorGrid
21
     */
22
    public function getTabulatorGrid(): TabulatorGrid
23
    {
24
        return $this->tabulatorGrid;
25
    }
26
27
    /**
28
     * Set the value of tabulatorGrid
29
     */
30
    public function setTabulatorGrid(TabulatorGrid $tabulatorGrid): self
31
    {
32
        $this->tabulatorGrid = $tabulatorGrid;
33
        return $this;
34
    }
35
36
    public function getName(): string
37
    {
38
        return $this->name;
39
    }
40
41
    public function setName($name): self
42
    {
43
        // Don't overwrite given name
44
        if ($name) {
45
            $this->name = $name;
46
        }
47
        return $this;
48
    }
49
50
    public function Link($action = null)
51
    {
52
        if (!$this->link) {
53
            return $this->tabulatorGrid->Link('tool/' . $this->name);
54
        }
55
        return $this->link;
56
    }
57
58
    public function isAdmini()
59
    {
60
        return $this->tabulatorGrid->getCompatLayer() instanceof AdminiCompat;
61
    }
62
63
    /**
64
     * Get the value of newWindow
65
     */
66
    public function getNewWindow(): bool
67
    {
68
        return $this->newWindow;
69
    }
70
71
    /**
72
     * Set the value of newWindow
73
     *
74
     * @param bool $newWindow
75
     */
76
    public function setNewWindow($newWindow): self
77
    {
78
        $this->newWindow = $newWindow;
79
        return $this;
80
    }
81
}
82