You are here

public function DrupalVariable::export in Devel 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Devel/Dumper/DrupalVariable.php \Drupal\devel\Plugin\Devel\Dumper\DrupalVariable::export()

Returns a string representation of a variable.

Parameters

mixed $input: The variable to export.

string $name: (optional) The label to output before variable, defaults to NULL.

Return value

string String representation of a variable.

Overrides DevelDumperInterface::export

1 call to DrupalVariable::export()
DrupalVariable::exportAsRenderable in src/Plugin/Devel/Dumper/DrupalVariable.php
Returns a string representation of a variable wrapped in a render array.

File

src/Plugin/Devel/Dumper/DrupalVariable.php, line 23

Class

DrupalVariable
Provides a DrupalVariable dumper plugin.

Namespace

Drupal\devel\Plugin\Devel\Dumper

Code

public function export($input, $name = NULL) {
  $name = $name ? $name . ' => ' : '';
  $dump = Variable::export($input);

  // Run Xss::filterAdmin on the resulting string to prevent
  // cross-site-scripting (XSS) vulnerabilities.
  $dump = Xss::filterAdmin($dump);
  $dump = '<pre>' . $name . $dump . '</pre>';
  return $this
    ->setSafeMarkup($dump);
}