aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/sidebar/ButtonElement.php
blob: f60fccfffbdf91a60b3ebe33016f20b86d1bb2bc (plain)
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
<?php
class ButtonElement extends WidgetElement implements ArrayAccess
{
    use AttributesArrayAccessTrait;

    public $label;
    public $icon = null;

    public function __construct(string $label, \Icon $icon = null, array $attributes = [])
    {
        parent::__construct();

        $this->label = $label;
        $this->icon = $icon;
        $this->attributes = $attributes;
    }

    public function render()
    {
        return sprintf(
            '<button %s>%s</button>',
            arrayToHtmlAttributes($this->attributes),
            htmlReady($this->label)
        );
    }
}