diff --git a/core/lib/Drupal/Core/Field/AllowedTagsXssTrait.php b/core/lib/Drupal/Core/Field/AllowedTagsXssTrait.php
index c356cc3d0cd..d893e1b3bdb 100644
--- a/core/lib/Drupal/Core/Field/AllowedTagsXssTrait.php
+++ b/core/lib/Drupal/Core/Field/AllowedTagsXssTrait.php
@@ -30,6 +30,7 @@ trait AllowedTagsXssTrait {
* valid UTF-8.
*/
public function fieldFilterXss($string) {
+ @trigger_error(__METHOD__ . ' is deprecated in drupal:8.0.0 and is removed in drupal:9.0.0. Use \Drupal\Core\Field\FieldFilteredMarkup::create() instead.', E_USER_DEPRECATED);
return FieldFilteredMarkup::create($string);
}
@@ -37,6 +38,7 @@ trait AllowedTagsXssTrait {
* Returns a list of tags allowed by AllowedTagsXssTrait::fieldFilterXss().
*/
public function allowedTags() {
+ @trigger_error(__METHOD__ . ' is deprecated in drupal:8.0.0 and is removed in drupal:9.0.0. Use \Drupal\Core\Field\FieldFilteredMarkup::allowedTags() instead.', E_USER_DEPRECATED);
return FieldFilteredMarkup::allowedTags();
}
@@ -44,6 +46,7 @@ trait AllowedTagsXssTrait {
* Returns a human-readable list of allowed tags for display in help texts.
*/
public function displayAllowedTags() {
+ @trigger_error(__METHOD__ . ' is deprecated in drupal:8.0.0 and is removed in drupal:9.0.0. Use \Drupal\Core\Field\FieldFilteredMarkup::displayAllowedTags() instead.', E_USER_DEPRECATED);
return FieldFilteredMarkup::displayAllowedTags();
}
diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php b/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php
index 416f7dc2ec6..855d5b46c34 100644
--- a/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php
+++ b/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php
@@ -2,6 +2,7 @@
namespace Drupal\options\Plugin\Field\FieldType;
+use Drupal\Core\Field\FieldFilteredMarkup;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\TypedData\DataDefinition;
@@ -55,7 +56,7 @@ class ListFloatItem extends ListItemBase {
$description .= '
' . t('The label is optional: if a line contains a single number, it will be used as key and label.');
$description .= '
' . t('Lists of labels are also accepted (one label per line), only if the field does not hold any values yet. Numeric keys will be automatically generated from the positions in the list.');
$description .= '
' . t('Allowed HTML tags in labels: @tags', ['@tags' => $this->displayAllowedTags()]) . '
'; + $description .= '' . t('Allowed HTML tags in labels: @tags', ['@tags' => FieldFilteredMarkup::displayAllowedTags()]) . '
'; return $description; } diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php b/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php index b8a4204806b..8a960075190 100644 --- a/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php +++ b/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php @@ -2,6 +2,7 @@ namespace Drupal\options\Plugin\Field\FieldType; +use Drupal\Core\Field\FieldFilteredMarkup; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\TypedData\DataDefinition; @@ -55,7 +56,7 @@ class ListIntegerItem extends ListItemBase { $description .= '' . t('Allowed HTML tags in labels: @tags', ['@tags' => $this->displayAllowedTags()]) . '
'; + $description .= '' . t('Allowed HTML tags in labels: @tags', ['@tags' => FieldFilteredMarkup::displayAllowedTags()]) . '
'; return $description; } diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php b/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php index 16e8878d7ab..55503076432 100644 --- a/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php +++ b/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php @@ -2,6 +2,7 @@ namespace Drupal\options\Plugin\Field\FieldType; +use Drupal\Core\Field\FieldFilteredMarkup; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\TypedData\DataDefinition; @@ -56,7 +57,7 @@ class ListStringItem extends ListItemBase { $description .= '' . t('Allowed HTML tags in labels: @tags', ['@tags' => $this->displayAllowedTags()]) . '
'; + $description .= '' . t('Allowed HTML tags in labels: @tags', ['@tags' => FieldFilteredMarkup::displayAllowedTags()]) . '
'; return $description; } diff --git a/core/tests/Drupal/Tests/Core/Field/AllowedTagsXssTraitDeprecateTest.php b/core/tests/Drupal/Tests/Core/Field/AllowedTagsXssTraitDeprecateTest.php new file mode 100644 index 00000000000..d018e154c10 --- /dev/null +++ b/core/tests/Drupal/Tests/Core/Field/AllowedTagsXssTraitDeprecateTest.php @@ -0,0 +1,37 @@ +assertSame('Test string', (string) $deprecated->fieldFilterXss('')); + $this->assertSame(FieldFilteredMarkup::allowedTags(), $deprecated->allowedTags()); + $this->assertSame(FieldFilteredMarkup::displayAllowedTags(), $deprecated->displayAllowedTags()); + } + +} + +/** + * Class FieldDeprecateAllowedTagsXssTraitClass + */ +class FieldDeprecateAllowedTagsXssTraitClass { + use AllowedTagsXssTrait; + +}