From 7c19368db58f16858fde7f1c5fe50c0d640c0482 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 13:45:00 +0200 Subject: Adding upstream version 1.1.2. Signed-off-by: Daniel Baumann --- library/Icingadb/Util/PluginOutput.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'library/Icingadb/Util/PluginOutput.php') diff --git a/library/Icingadb/Util/PluginOutput.php b/library/Icingadb/Util/PluginOutput.php index 71d08b1..03055a9 100644 --- a/library/Icingadb/Util/PluginOutput.php +++ b/library/Icingadb/Util/PluginOutput.php @@ -64,6 +64,9 @@ class PluginOutput extends HtmlString /** @var bool Whether the output contains HTML */ protected $isHtml; + /** @var int The maximum amount of characters to process */ + protected $characterLimit = 1000; + /** @var bool Whether output will be enriched */ protected $enrichOutput = true; @@ -93,6 +96,20 @@ class PluginOutput extends HtmlString return $this->isHtml; } + /** + * Set the maximum amount of characters to process + * + * @param int $limit + * + * @return $this + */ + public function setCharacterLimit(int $limit): self + { + $this->characterLimit = $limit; + + return $this; + } + /** * Set whether the output should be enriched * @@ -185,6 +202,10 @@ class PluginOutput extends HtmlString $output = $this->processHtml($output); } + if ($this->characterLimit) { + $output = substr($output, 0, $this->characterLimit); + } + $this->renderedOutput = $output; return $output; -- cgit v1.2.3