Skip to content

Commit 29989db

Browse files
authored
Refactor EscapeOrCleanHtml and Highlight View Helpers to use Autowiring (#5095)
1 parent 7241da7 commit 29989db

4 files changed

Lines changed: 10 additions & 86 deletions

File tree

module/VuFind/src/VuFind/View/Helper/Root/EscapeOrCleanHtml.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
namespace VuFind\View\Helper\Root;
3131

3232
use Laminas\Escaper\Escaper;
33-
use Laminas\View\Helper\AbstractHelper;
33+
use VuFind\ServiceManager\Factory\Autowire;
3434
use VuFind\String\PropertyStringInterface;
3535

3636
/**
@@ -42,7 +42,7 @@
4242
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
4343
* @link https://vufind.org/wiki/development Wiki
4444
*/
45-
class EscapeOrCleanHtml extends AbstractHelper
45+
class EscapeOrCleanHtml
4646
{
4747
/**
4848
* Contexts that allow HTML
@@ -58,8 +58,13 @@ class EscapeOrCleanHtml extends AbstractHelper
5858
* @param CleanHtml $cleanHtml Clean HTML helper
5959
* @param array $config VuFind configuration
6060
*/
61-
public function __construct(protected Escaper $escaper, protected CleanHtml $cleanHtml, array $config)
62-
{
61+
public function __construct(
62+
protected Escaper $escaper,
63+
#[Autowire(container: 'ViewHelperManager')]
64+
protected CleanHtml $cleanHtml,
65+
#[Autowire(config: 'config')]
66+
array $config
67+
) {
6368
$this->htmlContexts = (array)($config['Allowed_HTML_Contexts'] ?? []);
6469
}
6570

module/VuFind/src/VuFind/View/Helper/Root/EscapeOrCleanHtmlFactory.php

Lines changed: 0 additions & 77 deletions
This file was deleted.

module/VuFind/src/VuFind/View/Helper/Root/Highlight.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929

3030
namespace VuFind\View\Helper\Root;
3131

32-
use Laminas\View\Helper\AbstractHelper;
33-
3432
use function is_array;
3533

3634
/**
@@ -42,7 +40,7 @@
4240
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
4341
* @link https://vufind.org/wiki/development Wiki
4442
*/
45-
class Highlight extends AbstractHelper
43+
class Highlight
4644
{
4745
/**
4846
* Start tag for highlighting

themes/root/theme.config.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
'VuFind\View\Helper\Root\DateTime' => 'VuFind\View\Helper\Root\DateTimeFactory',
3131
'VuFind\View\Helper\Root\DeveloperSettings' => 'VuFind\View\Helper\Root\DeveloperSettingsFactory',
3232
'VuFind\View\Helper\Root\DisplayLanguageOption' => 'VuFind\View\Helper\Root\DisplayLanguageOptionFactory',
33-
'VuFind\View\Helper\Root\EscapeOrCleanHtml' => 'VuFind\View\Helper\Root\EscapeOrCleanHtmlFactory',
3433
'VuFind\View\Helper\Root\ExplainElement' => 'Laminas\ServiceManager\Factory\InvokableFactory',
3534
'VuFind\View\Helper\Root\Export' => 'VuFind\View\Helper\Root\ExportFactory',
3635
'VuFind\View\Helper\Root\Feedback' => 'VuFind\View\Helper\Root\FeedbackFactory',
@@ -39,7 +38,6 @@
3938
'VuFind\View\Helper\Root\GoogleAnalytics' => 'VuFind\View\Helper\Root\GoogleAnalyticsFactory',
4039
'VuFind\View\Helper\Root\GoogleTagManager' => 'VuFind\View\Helper\Root\GoogleTagManagerFactory',
4140
'VuFind\View\Helper\Root\HelpText' => 'VuFind\View\Helper\Root\HelpTextFactory',
42-
'VuFind\View\Helper\Root\Highlight' => 'Laminas\ServiceManager\Factory\InvokableFactory',
4341
'VuFind\View\Helper\Root\HistoryLabel' => 'VuFind\View\Helper\Root\HistoryLabelFactory',
4442
'VuFind\View\Helper\Root\Holdings' => 'VuFind\View\Helper\Root\HoldingsFactory',
4543
'VuFind\View\Helper\Root\HtmlSafeJsonEncode' => 'Laminas\ServiceManager\Factory\InvokableFactory',

0 commit comments

Comments
 (0)