diff --git a/lib/Helper/HTMLFilter/HtmlEntiryDecodeFilter.php b/lib/Helper/HTMLFilter/HtmlEntiryDecodeFilter.php index 5606d1eb..0afa3802 100644 --- a/lib/Helper/HTMLFilter/HtmlEntiryDecodeFilter.php +++ b/lib/Helper/HTMLFilter/HtmlEntiryDecodeFilter.php @@ -3,7 +3,7 @@ namespace OCA\Cookbook\Helper\HTMLFilter; class HtmlEntiryDecodeFilter extends AbstractHtmlFilter { - public function apply(string $html): void { + public function apply(string &$html): void { $html = html_entity_decode($html); } } diff --git a/lib/Helper/HTMLParser/HttpJsonLdParser.php b/lib/Helper/HTMLParser/HttpJsonLdParser.php index 971f8369..d4a08b3d 100644 --- a/lib/Helper/HTMLParser/HttpJsonLdParser.php +++ b/lib/Helper/HTMLParser/HttpJsonLdParser.php @@ -19,6 +19,8 @@ class HttpJsonLdParser extends AbstractHtmlParser { public function __construct(IL10N $l10n, JsonService $jsonService) { parent::__construct($l10n); + + $this->jsonService = $jsonService; } public function parse(\DOMDocument $document): array { diff --git a/lib/Service/HtmlDownloadService.php b/lib/Service/HtmlDownloadService.php index f2fbd6cf..caa161d3 100644 --- a/lib/Service/HtmlDownloadService.php +++ b/lib/Service/HtmlDownloadService.php @@ -199,32 +199,24 @@ class HtmlDownloadService { /** @var \LibXMLError $error */ $error = $by_error_code[$code]; - // Collect data for translations - $params = []; - $params['code'] = $error->code; - $params['count'] = $count; - $params['url'] = $url; - $params['line'] = $error->line; - $params['column'] = $error->column; - switch ($error->level) { case LIBXML_ERR_WARNING: - $error_message = $this->l->t("Warning {code} occurred {count} times while parsing {url}.", $params); + $error_message = $this->l->t('Warning %u occurred %u times while parsing %s.', [$error->code, $count, $url]); $return = max($return, self::PARSING_WARNING); break; case LIBXML_ERR_ERROR: - $error_message = $this->l->t("Error {code} occurred {count} times while parsing {url}.", $params); + $error_message = $this->l->t('Error %u occurred %u times while parsing %s.', [$error->code, $count, $url]); $return = max($return, self::PARSING_ERROR); break; case LIBXML_ERR_FATAL: - $error_message = $this->l->t("Fatal error {code} occurred {count} times while parsing {url}.", $params); + $error_message = $this->l->t('Fatal error %u occurred %count$u times while parsing %s.', [$error->code, $count, $url]); $return = max($return, self::PARSING_FATAL_ERROR); break; default: throw new \Exception($this->l->t('Unsupported error level during parsing of XML output.')); } - $last_occurence = $this->l->t('Last time it occurred in line {line} and column {column}', $params); + $last_occurence = $this->l->t('Last time it occurred in line %u and column %u', [$error->line, $error->column]); $error_message = "libxml: $error_message $last_occurence: " . $error->message; $this->logger->warning($error_message); diff --git a/lib/Service/RecipeExtractionService.php b/lib/Service/RecipeExtractionService.php index 3dfbb4fe..a38b963d 100644 --- a/lib/Service/RecipeExtractionService.php +++ b/lib/Service/RecipeExtractionService.php @@ -23,6 +23,7 @@ class RecipeExtractionService { public function __construct(HttpJsonLdParser $jsonParser, HttpMicrodataParser $microdataParser, IL10N $l10n) { $this->parsers = [$jsonParser, $microdataParser]; + $this->l = $l10n; } /**