Skip to content
Snippets Groups Projects

Issue #3480579: Minor code changes, coding standards

1 file
+ 6
6
Compare changes
  • Side-by-side
  • Inline
@@ -2,9 +2,9 @@
namespace Drupal\views_addons\Plugin\views\field;
use Drupal\views\Plugin\views\field\Custom;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\field\Custom;
/**
* A handler to provide a field that is completely custom by the administrator.
@@ -41,7 +41,7 @@ class CustomAdvanced extends Custom {
$form['additional_tags'] = [
'#title' => $this->t('Set additional allowed tags'),
'#type' => 'textfield',
'#default_value' => $this->options['additional_tags'] ? $this->options['additional_tags'] : 'svg g circle text',
'#default_value' => $this->options['additional_tags'] ?: 'svg g circle text',
'#help' => $this->t('List tags separated by space. (for example: "svg g circle text")'),
];
@@ -63,7 +63,7 @@ class CustomAdvanced extends Custom {
// Prepare the allowed tags string for strip_tags().
$allowedTagsString = '';
foreach ($allowedTags as $key => $tag) {
foreach ($allowedTags as $tag) {
$allowedTagsString .= '<' . $tag . '>';
}
@@ -80,7 +80,7 @@ class CustomAdvanced extends Custom {
// This foreach loop is copied from PluginBase.php.
$twig_tokens = [];
foreach ($tokens as $token => $replacement) {
if (strpos($token, '{{') !== FALSE) {
if (str_contains($token, '{{')) {
// Twig wants a token replacement array stripped of curly-brackets.
$token = trim(str_replace(['{{', '}}'], '', $token));
}
@@ -112,13 +112,13 @@ class CustomAdvanced extends Custom {
'#template' => $text,
'#context' => $twig_tokens,
'#post_render' => [
function ($children, $elements) use ($allowedTagsString) {
function ($children) use ($allowedTagsString) {
return strip_tags($children, $allowedTagsString);
},
],
];
return (string) $this->getRenderer()->renderPlain($build);
return (string) $this->getRenderer()->renderInIsolation($build);
}
else {
return strip_tags($text, $allowedTagsString);
Loading