Undefined spamspan function error when using TwigExtension

Created on 10 May 2023, about 1 year ago

Problem/Motivation

When the spanspan filter is used in a twig template it causes a WSOD and displays Error: Call to undefined function Drupal\spamspan\TwigExtension\spamspan() in Drupal\spamspan\TwigExtension\SpamspanExtension->spamSpanFilter() (line 61 of modules/contrib/spamspan/src/TwigExtension/SpamspanExtension.php).

Steps to reproduce

Add the spamspan filter around an email in a twig template and visit the relevant page. eg.

{{ email|spamspan }}

Proposed resolution

Modify line 61 of SpamspanExtension.php to call the spamspan function as a Drupal service. eg.

return Xss::filter(\Drupal::service('spamspan')->spamspan($string), SpamspanInterface::ALLOWED_HTML);

πŸ› Bug report
Status

Closed: duplicate

Version

3.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom harrick

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024