|
1
|
|
|
<?php |
|
2
|
|
|
namespace Malezha\Menu\Element; |
|
3
|
|
|
|
|
4
|
|
|
use Malezha\Menu\Contracts\Attributes; |
|
5
|
|
|
use Malezha\Menu\Contracts\Builder; |
|
6
|
|
|
use Malezha\Menu\Contracts\ComparativeUrl; |
|
7
|
|
|
use Malezha\Menu\Contracts\HasBuilder; |
|
8
|
|
|
use Malezha\Menu\Contracts\MenuRender; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class SubMenu |
|
12
|
|
|
* @package Malezha\Menu\Element |
|
13
|
|
|
* |
|
14
|
|
|
* @property-read Attributes $activeAttributes |
|
15
|
|
|
* @property-read Builder $builder |
|
16
|
|
|
* @inheritdoc |
|
17
|
|
|
*/ |
|
18
|
|
|
class SubMenu extends Link implements HasBuilder |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @var Builder |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $builder; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* SubMenu constructor. |
|
27
|
|
|
* @param string $title |
|
28
|
|
|
* @param string $url |
|
29
|
|
|
* @param Attributes $attributes |
|
30
|
|
|
* @param Attributes $activeAttributes |
|
31
|
|
|
* @param Attributes $linkAttributes |
|
32
|
|
|
* @param string $view |
|
33
|
|
|
* @param ComparativeUrl $comparativeUrl |
|
34
|
|
|
* @param MenuRender $render |
|
35
|
|
|
* @param Builder $builder |
|
36
|
|
|
*/ |
|
37
|
6 |
|
public function __construct($title, $url, Attributes $attributes, Attributes $activeAttributes, |
|
38
|
|
|
Attributes $linkAttributes, $view, ComparativeUrl $comparativeUrl, |
|
39
|
|
|
MenuRender $render, Builder $builder) |
|
40
|
|
|
{ |
|
41
|
6 |
|
parent::__construct($title, $url, $attributes, $activeAttributes, $linkAttributes, $view, $comparativeUrl, $render); |
|
42
|
|
|
|
|
43
|
6 |
|
$this->builder = $builder; |
|
44
|
6 |
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @inheritDoc |
|
48
|
|
|
*/ |
|
49
|
1 |
|
public function getBuilder() |
|
50
|
|
|
{ |
|
51
|
1 |
|
return $this->builder; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @inheritdoc |
|
56
|
|
|
*/ |
|
57
|
6 |
|
public function renderWith() |
|
58
|
|
|
{ |
|
59
|
6 |
|
$renderView = func_get_arg(0); |
|
60
|
|
|
|
|
61
|
6 |
|
return array_merge(parent::renderWith(), [ |
|
62
|
6 |
|
'builder' => $this->builder, |
|
63
|
6 |
|
'renderView' => $renderView, |
|
64
|
|
|
]); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @inheritdoc |
|
69
|
|
|
*/ |
|
70
|
6 |
|
public function render($view = null) |
|
71
|
|
|
{ |
|
72
|
6 |
|
return $this->render->make($this->view) |
|
73
|
6 |
|
->with($this->renderWith($view)) |
|
74
|
6 |
|
->render(); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @inheritDoc |
|
79
|
|
|
*/ |
|
80
|
2 |
|
public function toArray() |
|
81
|
|
|
{ |
|
82
|
2 |
|
return array_merge(parent::toArray(), [ |
|
83
|
2 |
|
'builder' => $this->builder->toArray(), |
|
84
|
|
|
]); |
|
85
|
|
|
} |
|
86
|
|
|
} |