You are here

public static function SafeMarkup::isSafe in Drupal 8

Checks if a string is safe to output.

Parameters

string|\Drupal\Component\Render\MarkupInterface $string: The content to be checked.

string $strategy: (optional) This value is ignored.

Return value

bool TRUE if the string has been marked secure, FALSE otherwise.

Deprecated

in drupal:8.0.0 and is removed from drupal:9.0.0. Instead, you should just check if a variable is an instance of \Drupal\Component\Render\MarkupInterface.

See also

https://www.drupal.org/node/2549395

1 call to SafeMarkup::isSafe()
SafeMarkupTest::testIsSafe in core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php
Tests SafeMarkup::isSafe() with different objects.

File

core/lib/Drupal/Component/Utility/SafeMarkup.php, line 42

Class

SafeMarkup
Contains deprecated functionality related to sanitization of markup.

Namespace

Drupal\Component\Utility

Code

public static function isSafe($string, $strategy = 'html') {
  @trigger_error('SafeMarkup::isSafe() is scheduled for removal in Drupal 9.0.0. Instead, you should just check if a variable is an instance of \\Drupal\\Component\\Render\\MarkupInterface. See https://www.drupal.org/node/2549395.', E_USER_DEPRECATED);
  return $string instanceof MarkupInterface;
}