9df1aec5cf24623daa7d5b2fbd308aeb001a971d
[yaffs-website] / web / modules / contrib / devel / src / Plugin / Devel / Dumper / DoctrineDebug.php
1 <?php
2
3 namespace Drupal\devel\Plugin\Devel\Dumper;
4
5 use Doctrine\Common\Util\Debug;
6 use Drupal\Component\Utility\Xss;
7 use Drupal\devel\DevelDumperBase;
8
9 /**
10  * Provides a DoctrineDebug dumper plugin.
11  *
12  * @DevelDumper(
13  *   id = "default",
14  *   label = @Translation("Default"),
15  *   description = @Translation("Wrapper for <a href='http://www.doctrine-project.org/api/common/2.3/class-Doctrine.Common.Util.Debug.html'>Doctrine</a> debugging tool.")
16  * )
17  */
18 class DoctrineDebug extends DevelDumperBase {
19
20   /**
21    * {@inheritdoc}
22    */
23   public function export($input, $name = NULL) {
24     $name = $name ? $name . ' => ' : '';
25     $variable = Debug::export($input, 6);
26
27     ob_start();
28     print_r($variable);
29     $dump = ob_get_contents();
30     ob_end_clean();
31
32     // Run Xss::filterAdmin on the resulting string to prevent
33     // cross-site-scripting (XSS) vulnerabilities.
34     $dump = Xss::filterAdmin($dump);
35
36     $dump = '<pre>' . $name . $dump . '</pre>';
37
38     return $this->setSafeMarkup($dump);
39   }
40
41   /**
42    * {@inheritdoc}
43    */
44   public function exportAsRenderable($input, $name = NULL) {
45     $output['container'] = [
46       '#type' => 'details',
47       '#title' => $name ? : $this->t('Variable'),
48       '#attached' => [
49         'library' => ['devel/devel']
50       ],
51       '#attributes' => [
52         'class' => ['container-inline', 'devel-dumper', 'devel-selectable'],
53       ],
54       'export' => [
55         '#markup' => $this->export($input),
56       ],
57     ];
58
59     return $output;
60   }
61
62   /**
63    * {@inheritdoc}
64    */
65   public static function checkRequirements() {
66     return TRUE;
67   }
68
69 }