Completed
Push — master ( 341a7d...fd15d4 )
by WEBEWEB
02:17
created

AbstractNavigationNode::setTarget()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * This file is part of the bootstrap-bundle package.
5
 *
6
 * (c) 2018 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\BootstrapBundle\Navigation;
13
14
use WBW\Library\Core\Node\AbstractNode;
15
16
/**
17
 * Abstract navigation node.
18
 *
19
 * @author webeweb <https://github.com/webeweb/>
20
 * @package WBW\Bundle\BootstrapBundle\Navigation
21
 * @abstract
22
 */
23
abstract class AbstractNavigationNode extends AbstractNode implements NavigationInterface {
24
25
    /**
26
     * Active ?
27
     *
28
     * @var boolean
29
     */
30
    private $active;
31
32
    /**
33
     * Enable ?
34
     *
35
     * @var boolean
36
     */
37
    private $enable;
38
39
    /**
40
     * Icon.
41
     *
42
     * @var string
43
     */
44
    private $icon;
45
46
    /**
47
     * Route.
48
     *
49
     * @var string
50
     */
51
    private $route;
52
53
    /**
54
     * Target.
55
     *
56
     * @var string
57
     */
58
    private $target;
59
60
    /**
61
     * Visible ?
62
     *
63
     * @var boolean
64
     */
65
    private $visible;
66
67
    /**
68
     * Constructor.
69
     *
70
     * @param string $name The name.
71
     * @param string $icon The icon.
72
     * @param string $route The route.
73
     */
74
    protected function __construct($name, $icon = null, $route = self::DEFAULT_HREF) {
75
        parent::__construct($name);
76
        $this->active  = false;
77
        $this->enable  = false;
78
        $this->icon    = $icon;
79
        $this->route   = $route;
80
        $this->target  = null;
81
        $this->visible = true;
82
    }
83
84
    /**
85
     * Get the active.
86
     *
87
     * @return boolean Returns the active.
88
     */
89
    final public function getActive() {
90
        return $this->active;
91
    }
92
93
    /**
94
     * Get the enable.
95
     *
96
     * @return boolean Returns the enable.
97
     */
98
    final public function getEnable() {
99
        return $this->enable;
100
    }
101
102
    /**
103
     * Get the icon.
104
     *
105
     * @return string Returns the icon.
106
     */
107
    final public function getIcon() {
108
        return $this->icon;
109
    }
110
111
    /**
112
     * Get the route.
113
     *
114
     * @return string Returns the route.
115
     */
116
    final public function getRoute() {
117
        return $this->route;
118
    }
119
120
    /**
121
     * Get the target.
122
     *
123
     * @return string Returns the target.
124
     */
125
    final public function getTarget() {
126
        return $this->target;
127
    }
128
129
    /**
130
     * Get the visible.
131
     *
132
     * @return boolean Returns the visible.
133
     */
134
    final public function getVisible() {
135
        return $this->visible;
136
    }
137
138
    /**
139
     * Determines if the node is displayable.
140
     *
141
     * @return boolean Returns true in case of success, false otherwise.
142
     */
143
    final public function isDisplayable() {
144
        $displayable = $this->enable && $this->visible;
145
        if (true === $displayable) {
146
            return true;
147
        }
148
        foreach ($this->getNodes() as $current) {
149
            if (false === ($current instanceof AbstractNavigationNode)) {
150
                continue;
151
            }
152
            if (true === $current->isDisplayable()) {
153
                return true;
154
            }
155
        }
156
        return $displayable;
157
    }
158
159
    /**
160
     * Set the active.
161
     *
162
     * @param boolean $active Active ?
163
     * @return NavigationNode Returns the navigation node.
164
     */
165
    final public function setActive($active) {
166
        $this->active = $active;
167
        return $this;
168
    }
169
170
    /**
171
     * Set the enable.
172
     *
173
     * @param boolean $enable Enable ?.
174
     * @return NavigationNode Returns the navigation node.
175
     */
176
    final public function setEnable($enable) {
177
        $this->enable = $enable;
178
        return $this;
179
    }
180
181
    /**
182
     * Set the icon.
183
     *
184
     * @param string $icon The icon.
185
     * @return NavigationNode Returns the navigation node.
186
     */
187
    final public function setIcon($icon) {
188
        $this->icon = $icon;
189
        return $this;
190
    }
191
192
    /**
193
     * Set the route.
194
     *
195
     * @param string $route The route.
196
     * @return NavigationNode Returns the navigation node.
197
     */
198
    final public function setRoute($route) {
199
        $this->route = $route;
200
        return $this;
201
    }
202
203
    /**
204
     * Set the target.
205
     *
206
     * @param string $target The target.
207
     * @return NavigationNode Returns the navigation node.
208
     */
209
    final public function setTarget($target) {
210
        $this->target = $target;
211
        return $this;
212
    }
213
214
    /**
215
     * Set the visible.
216
     *
217
     * @param boolean $visible Visible ?
218
     * @return NavigationNode Returns the navigation node.
219
     */
220
    final protected function setVisible($visible) {
221
        $this->visible = $visible;
222
        return $this;
223
    }
224
225
}
226