1 | <?php |
||
10 | class WidgetGroup extends Collection |
||
11 | { |
||
12 | /** |
||
13 | * The separator to display between widgets in the group. |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $separator; |
||
18 | |||
19 | /** |
||
20 | * The callback that defines extra markup |
||
21 | * that wraps every widget in the group. |
||
22 | * |
||
23 | * @var callable |
||
24 | */ |
||
25 | protected $wrapCallback; |
||
26 | |||
27 | /** |
||
28 | * Render all widgets from the group in correct order. |
||
29 | * |
||
30 | * @return \Illuminate\Support\HtmlString |
||
31 | */ |
||
32 | public function render(): HtmlString |
||
44 | |||
45 | /** |
||
46 | * Add a widget to the group. |
||
47 | * |
||
48 | * @param \Rinvex\Widgets\Models\AbstractWidget $widget |
||
49 | * @param int $position |
||
50 | * |
||
51 | * @return $this |
||
52 | */ |
||
53 | public function addWidget(AbstractWidget $widget, int $position = 100) |
||
59 | |||
60 | /** |
||
61 | * Set a separator to display between widgets in the group. |
||
62 | * |
||
63 | * @param string $separator |
||
64 | * |
||
65 | * @return $this |
||
66 | */ |
||
67 | public function separateWith(string $separator) |
||
73 | |||
74 | /** |
||
75 | * Set the callback that defines extra markup |
||
76 | * that wraps every widget in the group. |
||
77 | * |
||
78 | * @param callable $callable |
||
79 | * |
||
80 | * @return $this |
||
81 | */ |
||
82 | public function wrapCallback(callable $callable) |
||
88 | |||
89 | /** |
||
90 | * Execute the callback that defines extra markup that |
||
91 | * wraps every widget in the group with a special markup. |
||
92 | * |
||
93 | * @param int $key |
||
94 | * @param \Illuminate\Support\HtmlString $widget |
||
95 | * |
||
96 | * @return string |
||
97 | */ |
||
98 | protected function performWrap(int $key, HtmlString $widget): string |
||
102 | } |
||
103 |