Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,13 @@ private function getContainerDefinitionData(Definition $definition, $omitTags =
'lazy' => $definition->isLazy(),
'shared' => $definition->isShared(),
'abstract' => $definition->isAbstract(),
'autowire' => $definition->isAutowired(),
);

$autowiredCalls = array_values(array_filter($definition->getAutowiredCalls(), function ($method) {
return $method !== '__construct';
}));
$data['autowire'] = $definition->isAutowired() ? ($autowiredCalls ?: true) : false;

foreach ($definition->getAutowiringTypes(false) as $autowiringType) {
$data['autowiring_types'][] = $autowiringType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,16 @@ protected function describeContainerDefinition(Definition $definition, array $op
."\n".'- Lazy: '.($definition->isLazy() ? 'yes' : 'no')
."\n".'- Shared: '.($definition->isShared() ? 'yes' : 'no')
."\n".'- Abstract: '.($definition->isAbstract() ? 'yes' : 'no')
."\n".'- Autowired: '.($definition->isAutowired() ? 'yes' : 'no')
;

$autowiredCalls = array_filter($definition->getAutowiredCalls(), function ($method) {
return $method !== '__construct';
});
$output .= "\n".'- Autowire: ';
$output .= $definition->isAutowired() ? ($autowiredCalls ? implode(', ', array_map(function ($method) {
return "`$method`";
}, $autowiredCalls)) : 'yes') : 'no';

foreach ($definition->getAutowiringTypes(false) as $autowiringType) {
$output .= "\n".'- Autowiring Type: `'.$autowiringType.'`';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,11 @@ protected function describeContainerDefinition(Definition $definition, array $op
$tableRows[] = array('Lazy', $definition->isLazy() ? 'yes' : 'no');
$tableRows[] = array('Shared', $definition->isShared() ? 'yes' : 'no');
$tableRows[] = array('Abstract', $definition->isAbstract() ? 'yes' : 'no');
$tableRows[] = array('Autowired', $definition->isAutowired() ? 'yes' : 'no');

$autowiredCalls = array_filter($definition->getAutowiredCalls(), function ($method) {
return $method !== '__construct';
});
$tableRows[] = array('Autowire', $definition->isAutowired() ? ($autowiredCalls ? implode("\n", $autowiredCalls) : 'yes') : 'no');

if ($autowiringTypes = $definition->getAutowiringTypes(false)) {
$tableRows[] = array('Autowiring Types', implode(', ', $autowiringTypes));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,18 @@ private function getContainerDefinitionDocument(Definition $definition, $id = nu
$serviceXML->setAttribute('autowired', $definition->isAutowired() ? 'true' : 'false');
$serviceXML->setAttribute('file', $definition->getFile());

$autowiredCalls = array_filter($definition->getAutowiredCalls(), function ($method) {
return $method !== '__construct';
});
if ($autowiredCalls) {
$serviceXML->appendChild($autowiredMethodsXML = $dom->createElement('autowired-calls'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure we need this wrapper tag btw

Copy link
Contributor Author

@ogizanagi ogizanagi Feb 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me neither. But that's consistent with the way tags, calls, ... are dumped. (See https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_2.xml for instance)

foreach ($autowiredCalls as $autowiredMethod) {
$autowiredMethodXML = $dom->createElement('autowired-call');
$autowiredMethodXML->appendChild(new \DOMText($autowiredMethod));
$autowiredMethodsXML->appendChild($autowiredMethodXML);
}
}

$calls = $definition->getMethodCalls();
if (count($calls) > 0) {
$serviceXML->appendChild($callsXML = $dom->createElement('calls'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ public static function getContainerDefinitions()
->addTag('tag2')
->addMethodCall('setMailer', array(new Reference('mailer')))
->setFactory(array(new Reference('factory.service'), 'get')),
'definition_autowired' => (new Definition('AutowiredService'))->setAutowired(true),
'definition_autowired_with_methods' => (new Definition('AutowiredService'))
->setAutowiredCalls(array('__construct', 'set*', 'addFoo')),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
- Lazy: yes
- Shared: yes
- Abstract: yes
- Autowired: no
- Autowire: no
- Factory Class: `Full\Qualified\FactoryClass`
- Factory Method: `get`
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Lazy yes
Shared yes
Abstract yes
Autowired no
Autowire no
Factory Class Full\Qualified\FactoryClass
Factory Method get
---------------- -----------------------------
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- Lazy: no
- Shared: yes
- Abstract: no
- Autowired: no
- Autowire: no
- File: `/path/to/file`
- Factory Service: `factory.service`
- Factory Method: `get`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
Lazy no
Shared yes
Abstract no
Autowired no
Autowire no
Required File /path/to/file
Factory Service factory.service
Factory Method get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,33 @@
"factory_class": "Full\\Qualified\\FactoryClass",
"factory_method": "get",
"tags": []
},
"definition_autowired": {
"class": "AutowiredService",
"public": true,
"synthetic": false,
"lazy": false,
"shared": true,
"abstract": false,
"autowire": true,
"arguments": [],
"file": null,
"tags": []
},
"definition_autowired_with_methods": {
"class": "AutowiredService",
"public": true,
"synthetic": false,
"lazy": false,
"shared": true,
"abstract": false,
"autowire": [
"set*",
"addFoo"
],
"arguments": [],
"file": null,
"tags": []
}
},
"aliases": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,33 @@ Definitions
- Lazy: yes
- Shared: yes
- Abstract: yes
- Autowired: no
- Autowire: no
- Arguments: yes
- Factory Class: `Full\Qualified\FactoryClass`
- Factory Method: `get`

### definition_autowired

- Class: `AutowiredService`
- Public: yes
- Synthetic: no
- Lazy: no
- Shared: yes
- Abstract: no
- Autowire: yes
- Arguments: no

### definition_autowired_with_methods

- Class: `AutowiredService`
- Public: yes
- Synthetic: no
- Lazy: no
- Shared: yes
- Abstract: no
- Autowire: `set*`, `addFoo`
- Arguments: no


Aliases
-------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
Symfony Container Public Services
=================================

------------------- --------------------------------------------------------
 Service ID   Class name 
------------------- --------------------------------------------------------
alias_1 alias for "service_1"
alias_2 alias for "service_2"
definition_1 Full\Qualified\Class1
service_container Symfony\Component\DependencyInjection\ContainerBuilder
------------------- --------------------------------------------------------
----------------------------------- --------------------------------------------------------
 Service ID   Class name 
----------------------------------- --------------------------------------------------------
alias_1 alias for "service_1"
alias_2 alias for "service_2"
definition_1 Full\Qualified\Class1
definition_autowired AutowiredService
definition_autowired_with_methods AutowiredService
service_container Symfony\Component\DependencyInjection\ContainerBuilder
----------------------------------- --------------------------------------------------------

Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,12 @@
</argument>
<argument type="closure-proxy" id="definition1" method="get"/>
</definition>
<definition id="definition_autowired" class="AutowiredService" public="true" synthetic="false" lazy="false" shared="true" abstract="false" autowired="true" file=""/>
<definition id="definition_autowired_with_methods" class="AutowiredService" public="true" synthetic="false" lazy="false" shared="true" abstract="false" autowired="true" file="">
<autowired-calls>
<autowired-call>set*</autowired-call>
<autowired-call>addFoo</autowired-call>
</autowired-calls>
</definition>
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerBuilder"/>
</container>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,31 @@
"factory_class": "Full\\Qualified\\FactoryClass",
"factory_method": "get",
"tags": []
},
"definition_autowired": {
"class": "AutowiredService",
"public": true,
"synthetic": false,
"lazy": false,
"shared": true,
"abstract": false,
"autowire": true,
"file": null,
"tags": []
},
"definition_autowired_with_methods": {
"class": "AutowiredService",
"public": true,
"synthetic": false,
"lazy": false,
"shared": true,
"abstract": false,
"autowire": [
"set*",
"addFoo"
],
"file": null,
"tags": []
}
},
"aliases": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,30 @@ Definitions
- Lazy: yes
- Shared: yes
- Abstract: yes
- Autowired: no
- Autowire: no
- Factory Class: `Full\Qualified\FactoryClass`
- Factory Method: `get`

### definition_autowired

- Class: `AutowiredService`
- Public: yes
- Synthetic: no
- Lazy: no
- Shared: yes
- Abstract: no
- Autowire: yes

### definition_autowired_with_methods

- Class: `AutowiredService`
- Public: yes
- Synthetic: no
- Lazy: no
- Shared: yes
- Abstract: no
- Autowire: `set*`, `addFoo`


Aliases
-------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
Symfony Container Public Services
=================================

------------------- --------------------------------------------------------
 Service ID   Class name 
------------------- --------------------------------------------------------
alias_1 alias for "service_1"
alias_2 alias for "service_2"
definition_1 Full\Qualified\Class1
service_container Symfony\Component\DependencyInjection\ContainerBuilder
------------------- --------------------------------------------------------
----------------------------------- --------------------------------------------------------
 Service ID   Class name 
----------------------------------- --------------------------------------------------------
alias_1 alias for "service_1"
alias_2 alias for "service_2"
definition_1 Full\Qualified\Class1
definition_autowired AutowiredService
definition_autowired_with_methods AutowiredService
service_container Symfony\Component\DependencyInjection\ContainerBuilder
----------------------------------- --------------------------------------------------------

Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,12 @@
<definition id="definition_1" class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" autowired="false" file="">
<factory class="Full\Qualified\FactoryClass" method="get"/>
</definition>
<definition id="definition_autowired" class="AutowiredService" public="true" synthetic="false" lazy="false" shared="true" abstract="false" autowired="true" file=""/>
<definition id="definition_autowired_with_methods" class="AutowiredService" public="true" synthetic="false" lazy="false" shared="true" abstract="false" autowired="true" file="">
<autowired-calls>
<autowired-call>set*</autowired-call>
<autowired-call>addFoo</autowired-call>
</autowired-calls>
</definition>
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerBuilder"/>
</container>
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,31 @@
"parameters": []
}
]
},
"definition_autowired": {
"class": "AutowiredService",
"public": true,
"synthetic": false,
"lazy": false,
"shared": true,
"abstract": false,
"autowire": true,
"file": null,
"tags": []
},
"definition_autowired_with_methods": {
"class": "AutowiredService",
"public": true,
"synthetic": false,
"lazy": false,
"shared": true,
"abstract": false,
"autowire": [
"set*",
"addFoo"
],
"file": null,
"tags": []
}
},
"aliases": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Definitions
- Lazy: yes
- Shared: yes
- Abstract: yes
- Autowired: no
- Autowire: no
- Factory Class: `Full\Qualified\FactoryClass`
- Factory Method: `get`

Expand All @@ -24,7 +24,7 @@ Definitions
- Lazy: no
- Shared: yes
- Abstract: no
- Autowired: no
- Autowire: no
- File: `/path/to/file`
- Factory Service: `factory.service`
- Factory Method: `get`
Expand All @@ -36,6 +36,26 @@ Definitions
- Attr3: val3
- Tag: `tag2`

### definition_autowired

- Class: `AutowiredService`
- Public: yes
- Synthetic: no
- Lazy: no
- Shared: yes
- Abstract: no
- Autowire: yes

### definition_autowired_with_methods

- Class: `AutowiredService`
- Public: yes
- Synthetic: no
- Lazy: no
- Shared: yes
- Abstract: no
- Autowire: `set*`, `addFoo`


Aliases
-------
Expand All @@ -54,4 +74,4 @@ Aliases
Services
--------

- `service_container`: `Symfony\Component\DependencyInjection\ContainerBuilder`
- `service_container`: `Symfony\Component\DependencyInjection\ContainerBuilder`
Loading