From 9660d59ecbd19d51c8cac11eb4a91bb75de37aa4 Mon Sep 17 00:00:00 2001 From: moghwan Date: Fri, 12 Jul 2024 13:22:39 +0100 Subject: [PATCH 1/3] adding limit option to setValues for multiple values --- src/PhpWord/TemplateProcessor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index 8aee40c546..4948cadc81 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -362,10 +362,10 @@ public function setValue($search, $replace, $limit = self::MAXIMUM_REPLACEMENTS_ /** * Set values from a one-dimensional array of "variable => value"-pairs. */ - public function setValues(array $values): void + public function setValues(array $values, $limit = self::MAXIMUM_REPLACEMENTS_DEFAULT): void { foreach ($values as $macro => $replace) { - $this->setValue($macro, $replace); + $this->setValue($macro, $replace, $limit); } } From 5fbf82cad85dd1da7a16934aa6ec0ef0fb483817 Mon Sep 17 00:00:00 2001 From: moghwan Date: Fri, 12 Jul 2024 15:37:10 +0100 Subject: [PATCH 2/3] add parameter type --- src/PhpWord/TemplateProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index 4948cadc81..4474fbf2de 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -362,7 +362,7 @@ public function setValue($search, $replace, $limit = self::MAXIMUM_REPLACEMENTS_ /** * Set values from a one-dimensional array of "variable => value"-pairs. */ - public function setValues(array $values, $limit = self::MAXIMUM_REPLACEMENTS_DEFAULT): void + public function setValues(array $values, int $limit = self::MAXIMUM_REPLACEMENTS_DEFAULT): void { foreach ($values as $macro => $replace) { $this->setValue($macro, $replace, $limit); From 8ae73127a7ae074561a0566a2208f079d97bb377 Mon Sep 17 00:00:00 2001 From: moghwan Date: Fri, 12 Jul 2024 15:56:01 +0100 Subject: [PATCH 3/3] Update 2.0.0.md --- docs/changes/2.x/2.0.0.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changes/2.x/2.0.0.md b/docs/changes/2.x/2.0.0.md index c5fbaf4b52..6d8d7cf0d1 100644 --- a/docs/changes/2.x/2.0.0.md +++ b/docs/changes/2.x/2.0.0.md @@ -24,5 +24,6 @@ - Bump symfony/process from 5.4.28 to 5.4.34 by [@dependabot](https://github.com/dependabot) in [#2536](https://github.com/PHPOffice/PHPWord/pull/2536) - Allow rgb() when converting Html by [@oleibman](https://github.com/oleibman) fixing [#2508](https://github.com/PHPOffice/PHPWord/issues/2508) in [#2512](https://github.com/PHPOffice/PHPWord/pull/2512) - Improved Issue Template by [@Progi1984](https://github.com/Progi1984) in [#2609](https://github.com/PHPOffice/PHPWord/pull/2609) +- Adding the possibility to use iterate search and replace with setValues by [@moghwan](https://github.com/moghwan) in [#2632](https://github.com/PHPOffice/PHPWord/pull/2632) ### BC Breaks