From 3de74e58b710e7b8da572af3a3a309c57bfb2314 Mon Sep 17 00:00:00 2001 From: kasimi <mail@kasimi.net> Date: Wed, 22 Apr 2020 13:26:31 +0200 Subject: [PATCH] [ticket/16456] Add event core.text_formatter_s9e_get_errors PHPBB3-16456 --- phpBB/phpbb/textformatter/s9e/parser.php | 25 ++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/textformatter/s9e/parser.php b/phpBB/phpbb/textformatter/s9e/parser.php index f7e4668980..1151f09898 100644 --- a/phpBB/phpbb/textformatter/s9e/parser.php +++ b/phpBB/phpbb/textformatter/s9e/parser.php @@ -35,7 +35,7 @@ class parser implements \phpbb\textformatter\parser_interface /** * Constructor * - * @param \phpbb\cache\driver_interface $cache + * @param \phpbb\cache\driver\driver_interface $cache * @param string $key Cache key * @param factory $factory * @param \phpbb\event\dispatcher_interface $dispatcher @@ -197,7 +197,9 @@ class parser implements \phpbb\textformatter\parser_interface public function get_errors() { $errors = array(); - foreach ($this->parser->getLogger()->getLogs() as $entry) + $entries = $this->parser->getLogger()->getLogs(); + + foreach ($entries as $entry) { list(, $msg, $context) = $entry; @@ -237,6 +239,25 @@ class parser implements \phpbb\textformatter\parser_interface $errors = array_map('unserialize', array_unique(array_map('serialize', $errors))); } + $parser = $this; + + /** + * Modify error messages generated by the s9e\TextFormatter's logger + * + * @event core.text_formatter_s9e_get_errors + * @var parser parser This parser service + * @var array entries s9e\TextFormatter's logger entries + * @var array errors Error arrays with language key and optional arguments + * @since 3.2.10-RC1 + * @since 3.3.1-RC1 + */ + $vars = [ + 'parser', + 'entries', + 'errors', + ]; + extract($this->dispatcher->trigger_event('core.text_formatter_s9e_get_errors', compact($vars))); + return $errors; }