-
Notifications
You must be signed in to change notification settings - Fork 1
/
Nav.php
48 lines (40 loc) · 1.07 KB
/
Nav.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace iutbay\yii2bootstrap;
use yii\helpers\ArrayHelper;
use iutbay\yii2fontawesome\FontAwesome as FA;
/**
* Nav widget
* @author Kevin LEVRON <[email protected]>
*/
class Nav extends \yii\bootstrap\Nav
{
/**
* Renders the widget.
*/
public function run()
{
// icon support
foreach ($this->items as &$item) {
if (isset($item['icon'])) {
$icon = FA::icon($item['icon']);
$item['label'] = trim($icon . ' ' . ArrayHelper::getValue($item, 'label', ''));
$item['encode'] = false;
unset($item['icon']);
}
}
return parent::run();
}
/**
* @inheritdoc
*/
protected function renderDropdown($items, $parentItem)
{
return Dropdown::widget([
'options' => ArrayHelper::getValue($parentItem, 'dropDownOptions', []),
'items' => $items,
'encodeLabels' => $this->encodeLabels,
'clientOptions' => false,
'view' => $this->getView(),
]);
}
}