summaryrefslogtreecommitdiffstats
path: root/vendor/ipl/web/src/Widget/ContinueWith.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:38:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:38:04 +0000
commit1ff5c35de5dbd70a782875a91dd2232fd01b002b (patch)
tree77d9ce5e1bf78b3e6ef79f8f6e7861e2ced3c09b /vendor/ipl/web/src/Widget/ContinueWith.php
parentInitial commit. (diff)
downloadicinga-php-library-upstream/0.10.1.tar.xz
icinga-php-library-upstream/0.10.1.zip
Adding upstream version 0.10.1.upstream/0.10.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/ipl/web/src/Widget/ContinueWith.php')
-rw-r--r--vendor/ipl/web/src/Widget/ContinueWith.php72
1 files changed, 72 insertions, 0 deletions
diff --git a/vendor/ipl/web/src/Widget/ContinueWith.php b/vendor/ipl/web/src/Widget/ContinueWith.php
new file mode 100644
index 0000000..4aaf52e
--- /dev/null
+++ b/vendor/ipl/web/src/Widget/ContinueWith.php
@@ -0,0 +1,72 @@
+<?php
+
+namespace ipl\Web\Widget;
+
+use ipl\Html\Attributes;
+use ipl\Html\BaseHtmlElement;
+use ipl\Html\HtmlElement;
+use ipl\Stdlib\Filter;
+use ipl\Web\Common\BaseTarget;
+use ipl\Web\Filter\QueryString;
+use ipl\Web\Url;
+
+class ContinueWith extends BaseHtmlElement
+{
+ use BaseTarget;
+
+ protected $tag = 'span';
+
+ protected $defaultAttributes = ['class' => 'continue-with'];
+
+ /** @var Url */
+ protected $url;
+
+ /** @var Filter\Rule|callable */
+ protected $filter;
+
+ /** @var string */
+ protected $title;
+
+ public function __construct(Url $url, $filter)
+ {
+ $this->url = $url;
+ $this->filter = $filter;
+ }
+
+ /**
+ * Set title for the anchor
+ *
+ * @param string $title
+ *
+ * @return $this
+ */
+ public function setTitle($title)
+ {
+ $this->title = $title;
+
+ return $this;
+ }
+
+ public function assemble()
+ {
+ $filter = $this->filter;
+ if (is_callable($filter)) {
+ $filter = $filter(); /** @var Filter\Rule $filter */
+ }
+
+ if ($filter instanceof Filter\Chain && $filter->isEmpty()) {
+ $this->addHtml(new HtmlElement(
+ 'span',
+ Attributes::create(['class' => ['control-button', 'disabled']]),
+ new Icon('share')
+ ));
+ } else {
+ $this->addHtml(new ActionLink(
+ null,
+ $this->url->setQueryString(QueryString::render($filter)),
+ 'share',
+ ['class' => 'control-button', 'title' => $this->title]
+ ));
+ }
+ }
+}