summaryrefslogtreecommitdiffstats
path: root/library/Director/Web/Widget/AbstractList.php
blob: ad1b9e369b2ba54cdfa5014ad39283f3ba5bd1de (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php

namespace Icinga\Module\Director\Web\Widget;

use ipl\Html\Attributes;
use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;
use ipl\Html\HtmlElement;

class AbstractList extends BaseHtmlElement
{
    protected $contentSeparator = "\n";

    /**
     * AbstractList constructor.
     * @param array $items
     * @param null $attributes
     */
    public function __construct(array $items = [], $attributes = null)
    {
        foreach ($items as $item) {
            $this->addItem($item);
        }

        if ($attributes !== null) {
            $this->addAttributes($attributes);
        }
    }

    /**
     * @param Html|array|string $content
     * @param Attributes|array $attributes
     *
     * @return $this
     */
    public function addItem($content, $attributes = null)
    {
        return $this->add(HtmlElement::create('li', $attributes, $content));
    }
}