[Drupal] How to correct check_plain error in Drupal 8
While am working with Drupal 7 to Drupal 8 module migration I have faced the following issue.
Fatal error: Call to undefined function check_plain().As Zyxware is a regular contributor to Drupal, its relevant that we need to upgrade our contibuted modules too.
check_plain : Encodes special characters in a plain-text string for display as HTML.while we using check_plain() the string passed through the function is supposed to be used as plain text.
So we find out check_plain() have no more use in Drupal 8. :( and they implemented Drupal\Component\Utility\String::checkPlain(). :)
So we will use Drupal\Component\Utility\String::checkPlain()
For everytime its difficult for us to write the whole thing "Drupal\Component\Utility\String::checkPlain()",so we want use namespace and
String::checkPlain()
so where ever you have check_plain() replace with String::checkPlain() and use Drupal\Component\Utility\String at the top of it
Example:
Drupal 7:
$keys = check_plain($keys);
Drupal 8:
use Drupal\Component\Utility\String;
$keys = String::checkPlain($keys);