[FrameworkBundle] Autowiring support for debug:container

This commit is contained in:
Kévin Dunglas 2015-11-03 15:44:08 -08:00
parent 18913e15d5
commit 9c3b910849
32 changed files with 156 additions and 82 deletions

View File

@ -228,6 +228,16 @@ class JsonDescriptor extends Descriptor
} }
$data['abstract'] = $definition->isAbstract(); $data['abstract'] = $definition->isAbstract();
if (method_exists($definition, 'isAutowired')) {
$data['autowire'] = $definition->isAutowired();
$data['autowiring_types'] = array();
foreach ($definition->getAutowiringTypes() as $autowiringType) {
$data['autowiring_types'][] = $autowiringType;
}
}
$data['file'] = $definition->getFile(); $data['file'] = $definition->getFile();
if ($definition->getFactoryClass(false)) { if ($definition->getFactoryClass(false)) {

View File

@ -195,6 +195,14 @@ class MarkdownDescriptor extends Descriptor
$output .= "\n".'- Abstract: '.($definition->isAbstract() ? 'yes' : 'no'); $output .= "\n".'- Abstract: '.($definition->isAbstract() ? 'yes' : 'no');
if (method_exists($definition, 'isAutowired')) {
$output .= "\n".'- Autowired: '.($definition->isAutowired() ? 'yes' : 'no');
foreach ($definition->getAutowiringTypes() as $autowiringType) {
$output .= "\n".'- Autowiring Type: `'.$autowiringType.'`';
}
}
if ($definition->getFile()) { if ($definition->getFile()) {
$output .= "\n".'- File: `'.$definition->getFile().'`'; $output .= "\n".'- File: `'.$definition->getFile().'`';
} }

View File

@ -288,6 +288,19 @@ class TextDescriptor extends Descriptor
} }
$tableRows[] = array('Abstract', $definition->isAbstract() ? 'yes' : 'no'); $tableRows[] = array('Abstract', $definition->isAbstract() ? 'yes' : 'no');
if (method_exists($definition, 'isAutowired')) {
$tableRows[] = array('Autowired', $definition->isAutowired() ? 'yes' : 'no');
$autowiringTypes = $definition->getAutowiringTypes();
if (count($autowiringTypes)) {
$autowiringTypesInformation = implode(', ', $autowiringTypes);
} else {
$autowiringTypesInformation = '-';
}
$tableRows[] = array('Autowiring Types', $autowiringTypesInformation);
}
if ($definition->getFile()) { if ($definition->getFile()) {
$tableRows[] = array('Required File', $definition->getFile() ? $definition->getFile() : '-'); $tableRows[] = array('Required File', $definition->getFile() ? $definition->getFile() : '-');
} }

View File

@ -373,6 +373,11 @@ class XmlDescriptor extends Descriptor
$serviceXML->setAttribute('synchronized', $definition->isSynchronized(false) ? 'true' : 'false'); $serviceXML->setAttribute('synchronized', $definition->isSynchronized(false) ? 'true' : 'false');
} }
$serviceXML->setAttribute('abstract', $definition->isAbstract() ? 'true' : 'false'); $serviceXML->setAttribute('abstract', $definition->isAbstract() ? 'true' : 'false');
if (method_exists($definition, 'isAutowired')) {
$serviceXML->setAttribute('autowired', $definition->isAutowired() ? 'true' : 'false');
}
$serviceXML->setAttribute('file', $definition->getFile()); $serviceXML->setAttribute('file', $definition->getFile());
if (!$omitTags) { if (!$omitTags) {

View File

@ -14,7 +14,9 @@
"factory_method": "get", "factory_method": "get",
"tags": [ "tags": [
] ],
"autowire": false,
"autowiring_types": []
} }
}, },
"aliases": { "aliases": {

View File

@ -15,6 +15,7 @@ definition_1
- Shared: yes - Shared: yes
- Synchronized: no - Synchronized: no
- Abstract: yes - Abstract: yes
- Autowired: no
- Factory Class: `Full\Qualified\FactoryClass` - Factory Class: `Full\Qualified\FactoryClass`
- Factory Method: `get` - Factory Method: `get`

View File

@ -2,7 +2,7 @@
<container> <container>
<alias id="alias_1" service="service_1" public="true"/> <alias id="alias_1" service="service_1" public="true"/>
<alias id="alias_2" service="service_2" public="false"/> <alias id="alias_2" service="service_2" public="false"/>
<definition id="definition_1" class="Full\Qualified\Class1" scope="container" public="true" synthetic="false" lazy="true" shared="true" synchronized="false" abstract="true" file=""> <definition id="definition_1" class="Full\Qualified\Class1" scope="container" public="true" synthetic="false" lazy="true" shared="true" synchronized="false" abstract="true" autowired="false" file="">
<factory class="Full\Qualified\FactoryClass" method="get"/> <factory class="Full\Qualified\FactoryClass" method="get"/>
</definition> </definition>
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerBuilder"/> <service id="service_container" class="Symfony\Component\DependencyInjection\ContainerBuilder"/>

View File

@ -14,7 +14,9 @@
"factory_method": "get", "factory_method": "get",
"tags": [ "tags": [
] ],
"autowire": false,
"autowiring_types": []
}, },
"definition_2": { "definition_2": {
"class": "Full\\Qualified\\Class2", "class": "Full\\Qualified\\Class2",
@ -48,7 +50,9 @@
] ]
} }
] ],
"autowire": false,
"autowiring_types": []
} }
}, },
"aliases": { "aliases": {

View File

@ -15,6 +15,7 @@ definition_1
- Shared: yes - Shared: yes
- Synchronized: no - Synchronized: no
- Abstract: yes - Abstract: yes
- Autowired: no
- Factory Class: `Full\Qualified\FactoryClass` - Factory Class: `Full\Qualified\FactoryClass`
- Factory Method: `get` - Factory Method: `get`
@ -29,6 +30,7 @@ definition_2
- Shared: yes - Shared: yes
- Synchronized: no - Synchronized: no
- Abstract: no - Abstract: no
- Autowired: no
- File: `/path/to/file` - File: `/path/to/file`
- Factory Service: `factory.service` - Factory Service: `factory.service`
- Factory Method: `get` - Factory Method: `get`

View File

@ -2,10 +2,10 @@
<container> <container>
<alias id="alias_1" service="service_1" public="true"/> <alias id="alias_1" service="service_1" public="true"/>
<alias id="alias_2" service="service_2" public="false"/> <alias id="alias_2" service="service_2" public="false"/>
<definition id="definition_1" class="Full\Qualified\Class1" scope="container" public="true" synthetic="false" lazy="true" shared="true" synchronized="false" abstract="true" file=""> <definition id="definition_1" class="Full\Qualified\Class1" scope="container" public="true" synthetic="false" lazy="true" shared="true" synchronized="false" abstract="true" autowired="false" file="">
<factory class="Full\Qualified\FactoryClass" method="get"/> <factory class="Full\Qualified\FactoryClass" method="get"/>
</definition> </definition>
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" shared="true" synchronized="false" abstract="false" file="/path/to/file"> <definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" shared="true" synchronized="false" abstract="false" autowired="false" file="/path/to/file">
<factory service="factory.service" method="get"/> <factory service="factory.service" method="get"/>
<tags> <tags>
<tag name="tag1"> <tag name="tag1">

View File

@ -32,7 +32,9 @@
] ]
} }
] ],
"autowire": false,
"autowiring_types": []
} }
}, },
"aliases": [ "aliases": [

View File

@ -15,6 +15,7 @@ definition_2
- Shared: yes - Shared: yes
- Synchronized: no - Synchronized: no
- Abstract: no - Abstract: no
- Autowired: no
- File: `/path/to/file` - File: `/path/to/file`
- Factory Service: `factory.service` - Factory Service: `factory.service`
- Factory Method: `get` - Factory Method: `get`

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<container> <container>
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" shared="true" synchronized="false" abstract="false" file="/path/to/file"> <definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" shared="true" synchronized="false" abstract="false" autowired="false" file="/path/to/file">
<factory service="factory.service" method="get"/> <factory service="factory.service" method="get"/>
<tags> <tags>
<tag name="tag1"> <tag name="tag1">

View File

@ -11,7 +11,9 @@
"abstract": false, "abstract": false,
"file": "\/path\/to\/file", "file": "\/path\/to\/file",
"factory_service": "factory.service", "factory_service": "factory.service",
"factory_method": "get" "factory_method": "get",
"autowire": false,
"autowiring_types": []
} }
], ],
"tag2": [ "tag2": [
@ -26,7 +28,9 @@
"abstract": false, "abstract": false,
"file": "\/path\/to\/file", "file": "\/path\/to\/file",
"factory_service": "factory.service", "factory_service": "factory.service",
"factory_method": "get" "factory_method": "get",
"autowire": false,
"autowiring_types": []
} }
] ]
} }

View File

@ -15,6 +15,7 @@ definition_2
- Shared: yes - Shared: yes
- Synchronized: no - Synchronized: no
- Abstract: no - Abstract: no
- Autowired: no
- File: `/path/to/file` - File: `/path/to/file`
- Factory Service: `factory.service` - Factory Service: `factory.service`
- Factory Method: `get` - Factory Method: `get`
@ -34,6 +35,7 @@ definition_2
- Shared: yes - Shared: yes
- Synchronized: no - Synchronized: no
- Abstract: no - Abstract: no
- Autowired: no
- File: `/path/to/file` - File: `/path/to/file`
- Factory Service: `factory.service` - Factory Service: `factory.service`
- Factory Method: `get` - Factory Method: `get`

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<container> <container>
<tag name="tag1"> <tag name="tag1">
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" shared="true" synchronized="false" abstract="false" file="/path/to/file"> <definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" shared="true" synchronized="false" abstract="false" autowired="false" file="/path/to/file">
<factory service="factory.service" method="get"/> <factory service="factory.service" method="get"/>
</definition> </definition>
</tag> </tag>
<tag name="tag2"> <tag name="tag2">
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" shared="true" synchronized="false" abstract="false" file="/path/to/file"> <definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" shared="true" synchronized="false" abstract="false" autowired="false" file="/path/to/file">
<factory service="factory.service" method="get"/> <factory service="factory.service" method="get"/>
</definition> </definition>
</tag> </tag>

View File

@ -12,5 +12,7 @@
"factory_method": "get", "factory_method": "get",
"tags": [ "tags": [
] ],
"autowire": false,
"autowiring_types": []
} }

View File

@ -6,5 +6,6 @@
- Shared: yes - Shared: yes
- Synchronized: no - Synchronized: no
- Abstract: yes - Abstract: yes
- Autowired: no
- Factory Class: `Full\Qualified\FactoryClass` - Factory Class: `Full\Qualified\FactoryClass`
- Factory Method: `get` - Factory Method: `get`

View File

@ -1,15 +1,17 @@
---------------- ----------------------------- ------------------ -----------------------------
Option Value Option Value
---------------- ----------------------------- ------------------ -----------------------------
Service ID - Service ID -
Class Full\Qualified\Class1 Class Full\Qualified\Class1
Tags - Tags -
Scope container Scope container
Public yes Public yes
Synthetic no Synthetic no
Lazy yes Lazy yes
Synchronized no Synchronized no
Abstract yes Abstract yes
Factory Class Full\Qualified\FactoryClass Autowired no
Factory Method get Autowiring Types -
---------------- ----------------------------- Factory Class Full\Qualified\FactoryClass
Factory Method get
------------------ -----------------------------

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<definition class="Full\Qualified\Class1" scope="container" public="true" synthetic="false" lazy="true" shared="true" synchronized="false" abstract="true" file=""> <definition class="Full\Qualified\Class1" scope="container" public="true" synthetic="false" lazy="true" shared="true" synchronized="false" abstract="true" autowired="false" file="">
<factory class="Full\Qualified\FactoryClass" method="get"/> <factory class="Full\Qualified\FactoryClass" method="get"/>
</definition> </definition>

View File

@ -30,5 +30,7 @@
] ]
} }
] ],
"autowire": false,
"autowiring_types": []
} }

View File

@ -6,6 +6,7 @@
- Shared: yes - Shared: yes
- Synchronized: no - Synchronized: no
- Abstract: no - Abstract: no
- Autowired: no
- File: `/path/to/file` - File: `/path/to/file`
- Factory Service: `factory.service` - Factory Service: `factory.service`
- Factory Method: `get` - Factory Method: `get`

View File

@ -1,16 +1,18 @@
----------------- ------------------------------------------------------- ------------------ -------------------------------------------------------
Option Value Option Value
----------------- ------------------------------------------------------- ------------------ -------------------------------------------------------
Service ID - Service ID -
Class Full\Qualified\Class2 Class Full\Qualified\Class2
Tags tag1 (attr1: val1, attr2: val2)tag1 (attr3: val3)tag2 Tags tag1 (attr1: val1, attr2: val2)tag1 (attr3: val3)tag2
Scope container Scope container
Public no Public no
Synthetic yes Synthetic yes
Lazy no Lazy no
Synchronized no Synchronized no
Abstract no Abstract no
Required File /path/to/file Autowired no
Factory Service factory.service Autowiring Types -
Factory Method get Required File /path/to/file
----------------- ------------------------------------------------------- Factory Service factory.service
Factory Method get
------------------ -------------------------------------------------------

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<definition class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" shared="true" synchronized="false" abstract="false" file="/path/to/file"> <definition class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" shared="true" synchronized="false" abstract="false" autowired="false" file="/path/to/file">
<factory service="factory.service" method="get"/> <factory service="factory.service" method="get"/>
<tags> <tags>
<tag name="tag1"> <tag name="tag1">

View File

@ -12,5 +12,7 @@
"factory_method": "get", "factory_method": "get",
"tags": [ "tags": [
] ],
"autowire": false,
"autowiring_types": []
} }

View File

@ -6,5 +6,6 @@
- Shared: yes - Shared: yes
- Synchronized: yes - Synchronized: yes
- Abstract: yes - Abstract: yes
- Autowired: no
- Factory Class: `Full\Qualified\FactoryClass` - Factory Class: `Full\Qualified\FactoryClass`
- Factory Method: `get` - Factory Method: `get`

View File

@ -1,15 +1,17 @@
---------------- ----------------------------- ------------------ -----------------------------
Option Value Option Value
---------------- ----------------------------- ------------------ -----------------------------
Service ID - Service ID -
Class Full\Qualified\Class1 Class Full\Qualified\Class1
Tags - Tags -
Scope container Scope container
Public yes Public yes
Synthetic no Synthetic no
Lazy yes Lazy yes
Synchronized yes Synchronized yes
Abstract yes Abstract yes
Factory Class Full\Qualified\FactoryClass Autowired no
Factory Method get Autowiring Types -
---------------- ----------------------------- Factory Class Full\Qualified\FactoryClass
Factory Method get
------------------ -----------------------------

View File

@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<definition class="Full\Qualified\Class1" factory-class="Full\Qualified\FactoryClass" factory-method="get" scope="container" public="true" synthetic="false" lazy="true" shared="true" synchronized="true" abstract="true" file=""/> <definition class="Full\Qualified\Class1" factory-class="Full\Qualified\FactoryClass" factory-method="get" scope="container" public="true" synthetic="false" lazy="true" shared="true" synchronized="true" abstract="true" autowired="false" file=""/>

View File

@ -30,5 +30,7 @@
] ]
} }
] ],
"autowire": false,
"autowiring_types": []
} }

View File

@ -6,6 +6,7 @@
- Shared: yes - Shared: yes
- Synchronized: no - Synchronized: no
- Abstract: no - Abstract: no
- Autowired: no
- File: `/path/to/file` - File: `/path/to/file`
- Factory Service: `factory.service` - Factory Service: `factory.service`
- Factory Method: `get` - Factory Method: `get`

View File

@ -1,16 +1,18 @@
----------------- ------------------------------------------------------- ------------------ -------------------------------------------------------
Option Value Option Value
----------------- ------------------------------------------------------- ------------------ -------------------------------------------------------
Service ID - Service ID -
Class Full\Qualified\Class2 Class Full\Qualified\Class2
Tags tag1 (attr1: val1, attr2: val2)tag1 (attr3: val3)tag2 Tags tag1 (attr1: val1, attr2: val2)tag1 (attr3: val3)tag2
Scope container Scope container
Public no Public no
Synthetic yes Synthetic yes
Lazy no Lazy no
Synchronized no Synchronized no
Abstract no Abstract no
Required File /path/to/file Autowired no
Factory Service factory.service Autowiring Types -
Factory Method get Required File /path/to/file
----------------- ------------------------------------------------------- Factory Service factory.service
Factory Method get
------------------ -------------------------------------------------------

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<definition class="Full\Qualified\Class2" factory-service="factory.service" factory-method="get" scope="container" public="false" synthetic="true" lazy="false" shared="true" synchronized="false" abstract="false" file="/path/to/file"> <definition class="Full\Qualified\Class2" factory-service="factory.service" factory-method="get" scope="container" public="false" synthetic="true" lazy="false" shared="true" synchronized="false" abstract="false" autowired="false" file="/path/to/file">
<tags> <tags>
<tag name="tag1"> <tag name="tag1">
<parameter name="attr1">val1</parameter> <parameter name="attr1">val1</parameter>