3f38d15f25a7b44f918bc75cf293d582051f7583
[yaffs-website] / web / modules / contrib / devel / src / Plugin / Devel / Dumper / DrupalVariable.php
1 <?php
2
3 namespace Drupal\devel\Plugin\Devel\Dumper;
4
5 use Drupal\Component\Utility\Variable;
6 use Drupal\devel\DevelDumperBase;
7
8 /**
9  * Provides a DrupalVariable dumper plugin.
10  *
11  * @DevelDumper(
12  *   id = "drupal_variable",
13  *   label = @Translation("Drupal variable."),
14  *   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.")
15  * )
16  */
17 class DrupalVariable extends DevelDumperBase {
18
19   /**
20    * {@inheritdoc}
21    */
22   public function export($input, $name = NULL) {
23     $name = $name ? $name . ' => ' : '';
24     $dump = '<pre>' . $name . Variable::export($input) . '</pre>';
25     return $this->setSafeMarkup($dump);
26   }
27
28   /**
29    * {@inheritdoc}
30    */
31   public function exportAsRenderable($input, $name = NULL) {
32     $output['container'] = [
33       '#type' => 'details',
34       '#title' => $name ? : $this->t('Variable'),
35       '#attached' => [
36         'library' => ['devel/devel']
37       ],
38       '#attributes' => [
39         'class' => ['container-inline', 'devel-dumper', 'devel-selectable'],
40       ],
41       'export' => [
42         '#markup' => $this->export($input),
43       ],
44     ];
45
46     return $output;
47   }
48
49   /**
50    * {@inheritdoc}
51    */
52   public static function checkRequirements() {
53     return TRUE;
54   }
55
56 }