Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / lib / Drupal / Component / DependencyInjection / Dumper / PhpArrayDumper.php
1 <?php
2
3 namespace Drupal\Component\DependencyInjection\Dumper;
4
5 use Symfony\Component\DependencyInjection\ContainerInterface;
6
7 /**
8  * PhpArrayDumper dumps a service container as a PHP array.
9  *
10  * The format of this dumper is a human-readable serialized PHP array, which is
11  * very similar to the YAML based format, but based on PHP arrays instead of
12  * YAML strings.
13  *
14  * It is human-readable, for a machine-optimized version based on this one see
15  * \Drupal\Component\DependencyInjection\Dumper\OptimizedPhpArrayDumper.
16  *
17  * @see \Drupal\Component\DependencyInjection\PhpArrayContainer
18  */
19 class PhpArrayDumper extends OptimizedPhpArrayDumper {
20
21   /**
22    * {@inheritdoc}
23    */
24   public function getArray() {
25     $this->serialize = FALSE;
26     return parent::getArray();
27   }
28
29   /**
30    * {@inheritdoc}
31    */
32   protected function dumpCollection($collection, &$resolve = FALSE) {
33     $code = [];
34
35     foreach ($collection as $key => $value) {
36       if (is_array($value)) {
37         $code[$key] = $this->dumpCollection($value);
38       }
39       else {
40         $code[$key] = $this->dumpValue($value);
41       }
42     }
43
44     return $code;
45   }
46
47   /**
48    * {@inheritdoc}
49    */
50   protected function getServiceCall($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) {
51     if ($invalid_behavior !== ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) {
52       return '@?' . $id;
53     }
54
55     return '@' . $id;
56   }
57
58   /**
59    * {@inheritdoc}
60    */
61   protected function getParameterCall($name) {
62     return '%' . $name . '%';
63   }
64
65   /**
66    * {@inheritdoc}
67    */
68   protected function supportsMachineFormat() {
69     return FALSE;
70   }
71
72 }