1: <?php
2:
3: declare(strict_types=1);
4:
5: namespace Atk4\Ui;
6:
7: /**
8: * An accordion item in Accordion.
9: *
10: * @method Accordion getOwner()
11: */
12: class AccordionSection extends View
13: {
14: public $defaultTemplate = 'accordion-section.html';
15:
16: /** @var string|null The accordion item title. */
17: public $title;
18:
19: /** @var VirtualPage|null The accordion item virtual page. */
20: public $virtualPage;
21:
22: /** @var string */
23: public $icon = 'dropdown';
24:
25: #[\Override]
26: protected function renderView(): void
27: {
28: parent::renderView();
29:
30: $this->template->set('icon', $this->icon);
31:
32: if ($this->title) {
33: $this->template->set('title', $this->title);
34: }
35:
36: if ($this->virtualPage) {
37: $this->template->set('itemId', $this->virtualPage->name);
38: $this->template->set('path', $this->virtualPage->getJsUrl('cut'));
39: } else {
40: // TODO hack to prevent rendering 'id=""'
41: $this->template->set('itemId', $this->name . '-vp-unused');
42: }
43: }
44: }
45: