Skip to content

Commit 1198841

Browse files
committed
impl. for classes extending Lister
1 parent 31e8d70 commit 1198841

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/Breadcrumb.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ class Breadcrumb extends Lister
1010

1111
public $defaultTemplate = 'breadcrumb.html';
1212

13+
/** @var string|null */
14+
public $title;
15+
1316
/** @var list<array{section: string, link: string|array<0|string, string|int|false>}> */
1417
public $path = [];
1518

@@ -43,7 +46,7 @@ public function addCrumb($section = null, $link = null)
4346
public function popTitle()
4447
{
4548
$title = array_pop($this->path);
46-
$this->set($title['section'] ?? '');
49+
$this->title = $title['section'];
4750

4851
return $this;
4952
}
@@ -69,5 +72,9 @@ protected function renderView(): void
6972
$this->setSource($this->path);
7073

7174
parent::renderView();
75+
76+
if ($this->title !== null) {
77+
$this->template->append('Content', $this->title);
78+
}
7279
}
7380
}

src/Dropdown.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,27 @@ class Dropdown extends Lister
1919
/** @var JsCallback|null Callback when a new value is selected in Dropdown. */
2020
public $cb;
2121

22+
/** @var string|null Set static contents of this view. */
23+
public $content;
24+
2225
/** @var array<string, mixed> As per Fomantic-UI dropdown options. */
2326
public $dropdownOptions = [];
2427

28+
/**
29+
* @param array<0|string, mixed>|string $label
30+
*/
31+
public function __construct($label = [])
32+
{
33+
$defaults = is_array($label) ? $label : [$label];
34+
35+
if (array_key_exists(0, $defaults)) {
36+
$defaults['content'] = $defaults[0];
37+
unset($defaults[0]);
38+
}
39+
40+
parent::__construct($defaults);
41+
}
42+
2543
#[\Override]
2644
protected function init(): void
2745
{
@@ -70,6 +88,10 @@ protected function renderView(): void
7088
$this->js(true)->dropdown($this->dropdownOptions);
7189

7290
parent::renderView();
91+
92+
if ($this->content !== null) {
93+
$this->template->append('Content', $this->content);
94+
}
7395
}
7496

7597
#[\Override]

0 commit comments

Comments
 (0)