Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/dependency-injection/Dumper/GraphvizDumper.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
9 * file that was distributed with this source code. | 9 * file that was distributed with this source code. |
10 */ | 10 */ |
11 | 11 |
12 namespace Symfony\Component\DependencyInjection\Dumper; | 12 namespace Symfony\Component\DependencyInjection\Dumper; |
13 | 13 |
14 use Symfony\Component\DependencyInjection\Argument\ArgumentInterface; | |
14 use Symfony\Component\DependencyInjection\Definition; | 15 use Symfony\Component\DependencyInjection\Definition; |
15 use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException; | 16 use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException; |
16 use Symfony\Component\DependencyInjection\Reference; | 17 use Symfony\Component\DependencyInjection\Reference; |
17 use Symfony\Component\DependencyInjection\Parameter; | 18 use Symfony\Component\DependencyInjection\Parameter; |
18 use Symfony\Component\DependencyInjection\ContainerBuilder; | 19 use Symfony\Component\DependencyInjection\ContainerBuilder; |
50 * * edge: The default options for edges | 51 * * edge: The default options for edges |
51 * * node.instance: The default options for services that are defined directly by object instances | 52 * * node.instance: The default options for services that are defined directly by object instances |
52 * * node.definition: The default options for services that are defined via service definition instances | 53 * * node.definition: The default options for services that are defined via service definition instances |
53 * * node.missing: The default options for missing services | 54 * * node.missing: The default options for missing services |
54 * | 55 * |
55 * @param array $options An array of options | |
56 * | |
57 * @return string The dot representation of the service container | 56 * @return string The dot representation of the service container |
58 */ | 57 */ |
59 public function dump(array $options = array()) | 58 public function dump(array $options = array()) |
60 { | 59 { |
61 foreach (array('graph', 'node', 'edge', 'node.instance', 'node.definition', 'node.missing') as $key) { | 60 foreach (array('graph', 'node', 'edge', 'node.instance', 'node.definition', 'node.missing') as $key) { |
109 private function addEdges() | 108 private function addEdges() |
110 { | 109 { |
111 $code = ''; | 110 $code = ''; |
112 foreach ($this->edges as $id => $edges) { | 111 foreach ($this->edges as $id => $edges) { |
113 foreach ($edges as $edge) { | 112 foreach ($edges as $edge) { |
114 $code .= sprintf(" node_%s -> node_%s [label=\"%s\" style=\"%s\"];\n", $this->dotize($id), $this->dotize($edge['to']), $edge['name'], $edge['required'] ? 'filled' : 'dashed'); | 113 $code .= sprintf(" node_%s -> node_%s [label=\"%s\" style=\"%s\"%s];\n", $this->dotize($id), $this->dotize($edge['to']), $edge['name'], $edge['required'] ? 'filled' : 'dashed', $edge['lazy'] ? ' color="#9999ff"' : ''); |
115 } | 114 } |
116 } | 115 } |
117 | 116 |
118 return $code; | 117 return $code; |
119 } | 118 } |
126 * @param bool $required | 125 * @param bool $required |
127 * @param string $name | 126 * @param string $name |
128 * | 127 * |
129 * @return array An array of edges | 128 * @return array An array of edges |
130 */ | 129 */ |
131 private function findEdges($id, array $arguments, $required, $name) | 130 private function findEdges($id, array $arguments, $required, $name, $lazy = false) |
132 { | 131 { |
133 $edges = array(); | 132 $edges = array(); |
134 foreach ($arguments as $argument) { | 133 foreach ($arguments as $argument) { |
135 if ($argument instanceof Parameter) { | 134 if ($argument instanceof Parameter) { |
136 $argument = $this->container->hasParameter($argument) ? $this->container->getParameter($argument) : null; | 135 $argument = $this->container->hasParameter($argument) ? $this->container->getParameter($argument) : null; |
137 } elseif (is_string($argument) && preg_match('/^%([^%]+)%$/', $argument, $match)) { | 136 } elseif (is_string($argument) && preg_match('/^%([^%]+)%$/', $argument, $match)) { |
138 $argument = $this->container->hasParameter($match[1]) ? $this->container->getParameter($match[1]) : null; | 137 $argument = $this->container->hasParameter($match[1]) ? $this->container->getParameter($match[1]) : null; |
139 } | 138 } |
140 | 139 |
141 if ($argument instanceof Reference) { | 140 if ($argument instanceof Reference) { |
141 $lazyEdge = $lazy; | |
142 | |
142 if (!$this->container->has((string) $argument)) { | 143 if (!$this->container->has((string) $argument)) { |
143 $this->nodes[(string) $argument] = array('name' => $name, 'required' => $required, 'class' => '', 'attributes' => $this->options['node.missing']); | 144 $this->nodes[(string) $argument] = array('name' => $name, 'required' => $required, 'class' => '', 'attributes' => $this->options['node.missing']); |
145 } elseif ('service_container' !== (string) $argument) { | |
146 $lazyEdge = $lazy || $this->container->getDefinition((string) $argument)->isLazy(); | |
144 } | 147 } |
145 | 148 |
146 $edges[] = array('name' => $name, 'required' => $required, 'to' => $argument); | 149 $edges[] = array('name' => $name, 'required' => $required, 'to' => $argument, 'lazy' => $lazyEdge); |
150 } elseif ($argument instanceof ArgumentInterface) { | |
151 $edges = array_merge($edges, $this->findEdges($id, $argument->getValues(), $required, $name, true)); | |
147 } elseif (is_array($argument)) { | 152 } elseif (is_array($argument)) { |
148 $edges = array_merge($edges, $this->findEdges($id, $argument, $required, $name)); | 153 $edges = array_merge($edges, $this->findEdges($id, $argument, $required, $name, $lazy)); |
149 } | 154 } |
150 } | 155 } |
151 | 156 |
152 return $edges; | 157 return $edges; |
153 } | 158 } |
183 if (array_key_exists($id, $container->getAliases())) { | 188 if (array_key_exists($id, $container->getAliases())) { |
184 continue; | 189 continue; |
185 } | 190 } |
186 | 191 |
187 if (!$container->hasDefinition($id)) { | 192 if (!$container->hasDefinition($id)) { |
188 $class = get_class('service_container' === $id ? $this->container : $container->get($id)); | 193 $nodes[$id] = array('class' => str_replace('\\', '\\\\', get_class($container->get($id))), 'attributes' => $this->options['node.instance']); |
189 $nodes[$id] = array('class' => str_replace('\\', '\\\\', $class), 'attributes' => $this->options['node.instance']); | |
190 } | 194 } |
191 } | 195 } |
192 | 196 |
193 return $nodes; | 197 return $nodes; |
194 } | 198 } |