diff options
Diffstat (limited to 'library/Icingadb/Util')
-rw-r--r-- | library/Icingadb/Util/PluginOutput.php | 21 |
1 files changed, 21 insertions, 0 deletions
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; @@ -94,6 +97,20 @@ class PluginOutput extends HtmlString } /** + * 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 * * @param bool $state @@ -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; |