Version 1
[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\devel\DevelDumperBase;
7
8 /**
9  * Provides a DoctrineDebug dumper plugin.
10  *
11  * @DevelDumper(
12  *   id = "default",
13  *   label = @Translation("Default"),
14  *   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.")
15  * )
16  */
17 class DoctrineDebug extends DevelDumperBase {
18
19   /**
20    * {@inheritdoc}
21    */
22   public function export($input, $name = NULL) {
23     $name = $name ? $name . ' => ' : '';
24     $variable = Debug::export($input, 6);
25
26     ob_start();
27     print_r($variable);
28     $dump = ob_get_contents();
29     ob_end_clean();
30
31     $dump = '<pre>' . $name . $dump . '</pre>';
32
33     return $this->setSafeMarkup($dump);
34   }
35
36   /**
37    * {@inheritdoc}
38    */
39   public function exportAsRenderable($input, $name = NULL) {
40     $output['container'] = [
41       '#type' => 'details',
42       '#title' => $name ? : $this->t('Variable'),
43       '#attached' => [
44         'library' => ['devel/devel']
45       ],
46       '#attributes' => [
47         'class' => ['container-inline', 'devel-dumper', 'devel-selectable'],
48       ],
49       'export' => [
50         '#markup' => $this->export($input),
51       ],
52     ];
53
54     return $output;
55   }
56
57   /**
58    * {@inheritdoc}
59    */
60   public static function checkRequirements() {
61     return TRUE;
62   }
63
64 }