Completed
Push — master ( 8d79bf...db8467 )
by Vitaliy
04:23
created

GridPartsAccessTrait::setComponent()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 1
nc 1
1
<?php
2
namespace ViewComponents\Grids;
3
4
use ViewComponents\ViewComponents\Base\ComponentInterface;
5
use ViewComponents\ViewComponents\Base\Compound\PartInterface;
6
use ViewComponents\ViewComponents\Base\ContainerComponentInterface;
7
use ViewComponents\ViewComponents\Base\ViewComponentInterface;
8
use ViewComponents\ViewComponents\Component\Html\Tag;
9
use ViewComponents\ViewComponents\Component\Part;
10
11
/**
12
 * Trait GridPartsAccessTrait
13
 *
14
 * @todo replace Grid::constant to static::constant if it would work
15
 */
16
trait GridPartsAccessTrait
17
{
18
    /**
19
     * @param $id
20
     * @param bool $extractView
21
     * @return null|PartInterface|ViewComponentInterface|Part
22
     */
23
    abstract public function getComponent($id, $extractView = true);
24
25
    /**
26
     * @param ComponentInterface|PartInterface $component
27
     * @param string|null $id
28
     * @param string|null $defaultParent
29
     * @return $this
30
     */
31
    abstract public function setComponent(ComponentInterface $component, $id = null, $defaultParent = null);
32
33
    /**
34
     * Returns component that renders 'table' HTML tag.
35
     *
36
     * @return Tag
37
     */
38
    public function getTable()
39
    {
40
        return $this->getComponent(Grid::TABLE_ID);
41
    }
42
43
    /**
44
     * Sets component for rendering 'table' tag.
45
     *
46
     * @param ComponentInterface $component
47
     * @return $this
48
     */
49
    public function setTable(ComponentInterface $component)
50
    {
51
        return $this->setComponent($component, Grid::TABLE_ID, Grid::FORM_ID);
52
    }
53
54
    /**
55
     * Returns component that renders 'thead' HTML tag.
56
     *
57
     * @return Tag
58
     */
59
    public function getTableHeading()
60
    {
61
        return $this->getComponent(Grid::TABLE_HEADING_ID);
62
    }
63
64
    /**
65
     * @param ComponentInterface $component
66
     * @return $this
67
     */
68
    public function setTableHeading(ComponentInterface $component)
69
    {
70
        return $this->setComponent($component, Grid::TABLE_HEADING_ID, Grid::TABLE_ID);
71
    }
72
73
    /**
74
     * Returns component that renders 'tbody' HTML tag.
75
     *
76
     * @return Tag
77
     */
78
    public function getTableBody()
79
    {
80
        return $this->getComponent(Grid::TABLE_BODY_ID);
81
    }
82
83
    /**
84
     * @param ComponentInterface $component
85
     * @return $this
86
     */
87
    public function setTableBody(ComponentInterface $component)
88
    {
89
        return $this->setComponent($component, Grid::TABLE_BODY_ID, Grid::TABLE_ID);
90
    }
91
92
    /**
93
     * Returns component that renders 'tfoot' HTML tag.
94
     *
95
     * @return Tag
96
     */
97
    public function getTableFooter()
98
    {
99
        return $this->getComponent(Grid::TABLE_FOOTER_ID);
100
    }
101
102
    /**
103
     * @param ComponentInterface $component
104
     * @return $this
105
     */
106
    public function setTableFooter(ComponentInterface $component)
107
    {
108
        return $this->setComponent($component, Grid::TABLE_FOOTER_ID, Grid::TABLE_ID);
109
    }
110
111
    /**
112
     * Returns component that renders 'tr' HTML tag containing column titles.
113
     * @return Tag
114
     */
115
    public function getTileRow()
116
    {
117
        return $this->getComponent(Grid::TITLE_ROW_ID);
118
    }
119
120
    /**
121
     * @param ComponentInterface $component
122
     * @return $this
123
     */
124
    public function setTitleRow(ComponentInterface $component)
125
    {
126
        return $this->setComponent($component, Grid::TITLE_ROW_ID, Grid::TABLE_HEADING_ID);
127
    }
128
129
    /**
130
     * @return ContainerComponentInterface
131
     */
132
    public function getControlRow()
133
    {
134
        return $this->getComponent(Grid::CONTROL_ROW_ID);
135
    }
136
137
    /**
138
     * @param ComponentInterface $component
139
     * @return $this
140
     */
141
    public function setControlRow(ComponentInterface $component)
142
    {
143
        return $this->setComponent($component, Grid::CONTROL_ROW_ID, Grid::TABLE_HEADING_ID);
144
    }
145
146
    /**
147
     * @param ComponentInterface $component
148
     * @return $this
149
     */
150
    public function setControlContainer(ComponentInterface $component)
151
    {
152
        return $this->setComponent($component, Grid::CONTROL_CONTAINER_ID, Grid::CONTROL_ROW_ID);
153
    }
154
155
    /**
156
     * @param ComponentInterface $component
157
     * @return $this
158
     */
159
    public function setSubmitButton(ComponentInterface $component)
160
    {
161
        return $this->setComponent($component, Grid::SUBMIT_BUTTON_ID, Grid::CONTROL_ROW_ID);
162
    }
163
164
    /**
165
     * @param ComponentInterface $component
166
     * @return $this
167
     */
168
    public function setListContainer(ComponentInterface $component)
169
    {
170
        return $this->setComponent($component, Grid::LIST_CONTAINER_ID, Grid::TABLE_BODY_ID);
171
    }
172
173
}
174