3 namespace Drupal\devel\Plugin\Devel\Dumper;
5 use Drupal\Component\Utility\Variable;
6 use Drupal\Component\Utility\Xss;
7 use Drupal\devel\DevelDumperBase;
10 * Provides a DrupalVariable dumper plugin.
13 * id = "drupal_variable",
14 * label = @Translation("Drupal variable."),
15 * description = @Translation("Wrapper for <a href='https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Component%21Utility%21Variable.php/class/Variable/8'>Drupal Variable</a> class.")
18 class DrupalVariable extends DevelDumperBase {
23 public function export($input, $name = NULL) {
24 $name = $name ? $name . ' => ' : '';
25 $dump = Variable::export($input);
26 // Run Xss::filterAdmin on the resulting string to prevent
27 // cross-site-scripting (XSS) vulnerabilities.
28 $dump = Xss::filterAdmin($dump);
29 $dump = '<pre>' . $name . $dump . '</pre>';
30 return $this->setSafeMarkup($dump);
36 public function exportAsRenderable($input, $name = NULL) {
37 $output['container'] = [
39 '#title' => $name ? : $this->t('Variable'),
41 'library' => ['devel/devel']
44 'class' => ['container-inline', 'devel-dumper', 'devel-selectable'],
47 '#markup' => $this->export($input),
57 public static function checkRequirements() {