@@ -76,7 +76,7 @@ protected function describeContainerService($service, array $options = array(),
7676 */
7777 protected function describeContainerServices (ContainerBuilder $ builder , array $ options = array ())
7878 {
79- $ this ->writeDocument ($ this ->getContainerServicesDocument ($ builder , isset ($ options ['tag ' ]) ? $ options ['tag ' ] : null , isset ($ options ['show_private ' ]) && $ options ['show_private ' ]));
79+ $ this ->writeDocument ($ this ->getContainerServicesDocument ($ builder , isset ($ options ['tag ' ]) ? $ options ['tag ' ] : null , isset ($ options ['show_private ' ]) && $ options ['show_private ' ], isset ( $ options [ ' show_arguments ' ]) && $ options [ ' show_arguments ' ] ));
8080 }
8181
8282 /**
@@ -273,10 +273,11 @@ private function getContainerTagsDocument(ContainerBuilder $builder, $showPrivat
273273 * @param mixed $service
274274 * @param string $id
275275 * @param ContainerBuilder|null $builder
276+ * @param bool $showArguments
276277 *
277278 * @return \DOMDocument
278279 */
279- private function getContainerServiceDocument ($ service , $ id , ContainerBuilder $ builder = null )
280+ private function getContainerServiceDocument ($ service , $ id , ContainerBuilder $ builder = null , $ showArguments = false )
280281 {
281282 $ dom = new \DOMDocument ('1.0 ' , 'UTF-8 ' );
282283
@@ -286,7 +287,7 @@ private function getContainerServiceDocument($service, $id, ContainerBuilder $bu
286287 $ dom ->appendChild ($ dom ->importNode ($ this ->getContainerDefinitionDocument ($ builder ->getDefinition ((string ) $ service ), (string ) $ service )->childNodes ->item (0 ), true ));
287288 }
288289 } elseif ($ service instanceof Definition) {
289- $ dom ->appendChild ($ dom ->importNode ($ this ->getContainerDefinitionDocument ($ service , $ id )->childNodes ->item (0 ), true ));
290+ $ dom ->appendChild ($ dom ->importNode ($ this ->getContainerDefinitionDocument ($ service , $ id, false , $ showArguments )->childNodes ->item (0 ), true ));
290291 } else {
291292 $ dom ->appendChild ($ serviceXML = $ dom ->createElement ('service ' ));
292293 $ serviceXML ->setAttribute ('id ' , $ id );
@@ -300,10 +301,11 @@ private function getContainerServiceDocument($service, $id, ContainerBuilder $bu
300301 * @param ContainerBuilder $builder
301302 * @param string|null $tag
302303 * @param bool $showPrivate
304+ * @param bool $showArguments
303305 *
304306 * @return \DOMDocument
305307 */
306- private function getContainerServicesDocument (ContainerBuilder $ builder , $ tag = null , $ showPrivate = false )
308+ private function getContainerServicesDocument (ContainerBuilder $ builder , $ tag = null , $ showPrivate = false , $ showArguments = false )
307309 {
308310 $ dom = new \DOMDocument ('1.0 ' , 'UTF-8 ' );
309311 $ dom ->appendChild ($ containerXML = $ dom ->createElement ('container ' ));
@@ -317,7 +319,7 @@ private function getContainerServicesDocument(ContainerBuilder $builder, $tag =
317319 continue ;
318320 }
319321
320- $ serviceXML = $ this ->getContainerServiceDocument ($ service , $ serviceId );
322+ $ serviceXML = $ this ->getContainerServiceDocument ($ service , $ serviceId, null , $ showArguments );
321323 $ containerXML ->appendChild ($ containerXML ->ownerDocument ->importNode ($ serviceXML ->childNodes ->item (0 ), true ));
322324 }
323325
@@ -331,7 +333,7 @@ private function getContainerServicesDocument(ContainerBuilder $builder, $tag =
331333 *
332334 * @return \DOMDocument
333335 */
334- private function getContainerDefinitionDocument (Definition $ definition , $ id = null , $ omitTags = false )
336+ private function getContainerDefinitionDocument (Definition $ definition , $ id = null , $ omitTags = false , $ showArguments = false )
335337 {
336338 $ dom = new \DOMDocument ('1.0 ' , 'UTF-8 ' );
337339 $ dom ->appendChild ($ serviceXML = $ dom ->createElement ('definition ' ));
@@ -382,6 +384,12 @@ private function getContainerDefinitionDocument(Definition $definition, $id = nu
382384 }
383385 }
384386
387+ if ($ showArguments ) {
388+ foreach ($ this ->getArgumentNodes ($ definition ->getArguments (), $ dom ) as $ node ) {
389+ $ serviceXML ->appendChild ($ node );
390+ }
391+ }
392+
385393 if (!$ omitTags ) {
386394 $ tags = $ definition ->getTags ();
387395
@@ -404,6 +412,43 @@ private function getContainerDefinitionDocument(Definition $definition, $id = nu
404412 return $ dom ;
405413 }
406414
415+ /**
416+ * @param array $arguments
417+ *
418+ * @return \DOMNode[]
419+ */
420+ private function getArgumentNodes (array $ arguments , \DOMDocument $ dom )
421+ {
422+ $ nodes = array ();
423+
424+ foreach ($ arguments as $ argumentKey => $ argument ) {
425+ $ argumentXML = $ dom ->createElement ('argument ' );
426+
427+ if (is_string ($ argumentKey )) {
428+ $ argumentXML ->setAttribute ('key ' , $ argumentKey );
429+ }
430+
431+ if ($ argument instanceof Reference) {
432+ $ argumentXML ->setAttribute ('type ' , 'service ' );
433+ $ argumentXML ->setAttribute ('id ' , (string ) $ argument );
434+ } elseif ($ argument instanceof Definition) {
435+ $ argumentXML ->appendChild ($ dom ->importNode ($ this ->getContainerDefinitionDocument ($ argument , null , false , true )->childNodes ->item (0 ), true ));
436+ } elseif (is_array ($ argument )) {
437+ $ argumentXML ->setAttribute ('type ' , 'collection ' );
438+
439+ foreach ($ this ->getArgumentNodes ($ argument , $ dom ) as $ childArgumenXML ) {
440+ $ argumentXML ->appendChild ($ childArgumenXML );
441+ }
442+ } else {
443+ $ argumentXML ->appendChild (new \DOMText ($ argument ));
444+ }
445+
446+ $ nodes [] = $ argumentXML ;
447+ }
448+
449+ return $ nodes ;
450+ }
451+
407452 /**
408453 * @param Alias $alias
409454 * @param string|null $id
0 commit comments