From be4626482ba8761da39746a6ac60d133d3852a0f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 13:45:00 +0200 Subject: Merging 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') 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