summaryrefslogtreecommitdiffstats
path: root/library/Icingadb/Common/BaseOrderedItemList.php
blob: 23ae7e95fc11a6388acde9cb43ecb722838d25ff (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
<?php

/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */

namespace Icinga\Module\Icingadb\Common;

use Icinga\Module\Icingadb\Common\BaseItemList;
use Icinga\Module\Icingadb\Widget\EmptyState;

/**
 * @method BaseOrderedListItem getItemClass()
 */
abstract class BaseOrderedItemList extends BaseItemList
{
    protected $tag = 'ol';

    protected function assemble()
    {
        $itemClass = $this->getItemClass();

        $i = 0;
        foreach ($this->data as $data) {
            $item = new $itemClass($data, $this);
            $item->setOrder($i++);

            $this->add($item);
        }

        if ($this->isEmpty()) {
            $this->setTag('div');
            $this->add(new EmptyState(t('No items found.')));
        }
    }
}