summaryrefslogtreecommitdiffstats
path: root/library/Icingadb/Widget/TagList.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--library/Icingadb/Widget/TagList.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/library/Icingadb/Widget/TagList.php b/library/Icingadb/Widget/TagList.php
new file mode 100644
index 0000000..6a28a9c
--- /dev/null
+++ b/library/Icingadb/Widget/TagList.php
@@ -0,0 +1,35 @@
+<?php
+
+/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
+
+namespace Icinga\Module\Icingadb\Widget;
+
+use ipl\Html\BaseHtmlElement;
+use ipl\Html\Html;
+use ipl\Web\Widget\Link;
+
+class TagList extends BaseHtmlElement
+{
+ protected $content = [];
+
+ protected $defaultAttributes = ['class' => 'tag-list'];
+
+ protected $tag = 'div';
+
+ public function addLink($content, $url): self
+ {
+ $this->content[] = new Link($content, $url);
+
+ return $this;
+ }
+
+ public function hasContent(): bool
+ {
+ return ! empty($this->content);
+ }
+
+ protected function assemble()
+ {
+ $this->add(Html::wrapEach($this->content, 'li'));
+ }
+}