[DI] Deprecate autowiring-types in favor of aliases
This commit is contained in:
parent
b4ff1c8767
commit
b11d391cb7
@ -14,6 +14,23 @@ Debug
|
|||||||
DependencyInjection
|
DependencyInjection
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
* Autowiring-types have been deprecated, use aliases instead.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader" public="false">
|
||||||
|
<autowiring-type>Doctrine\Common\Annotations\Reader</autowiring-type>
|
||||||
|
</service>
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader" public="false" />
|
||||||
|
<service id="Doctrine\Common\Annotations\Reader" alias="annotations.reader" public="false" />
|
||||||
|
```
|
||||||
|
|
||||||
* The `Reference` and `Alias` classes do not make service identifiers lowercase anymore.
|
* The `Reference` and `Alias` classes do not make service identifiers lowercase anymore.
|
||||||
|
|
||||||
* Case insensitivity of service identifiers is deprecated and will be removed in 4.0.
|
* Case insensitivity of service identifiers is deprecated and will be removed in 4.0.
|
||||||
|
@ -24,6 +24,23 @@ Debug
|
|||||||
DependencyInjection
|
DependencyInjection
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
* Autowiring-types have been removed, use aliases instead.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader" public="false">
|
||||||
|
<autowiring-type>Doctrine\Common\Annotations\Reader</autowiring-type>
|
||||||
|
</service>
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader" public="false" />
|
||||||
|
<service id="Doctrine\Common\Annotations\Reader" alias="annotations.reader" public="false" />
|
||||||
|
```
|
||||||
|
|
||||||
* Service identifiers are now case sensitive.
|
* Service identifiers are now case sensitive.
|
||||||
|
|
||||||
* The `Reference` and `Alias` classes do not make service identifiers lowercase anymore.
|
* The `Reference` and `Alias` classes do not make service identifiers lowercase anymore.
|
||||||
|
@ -220,10 +220,9 @@ class JsonDescriptor extends Descriptor
|
|||||||
'shared' => $definition->isShared(),
|
'shared' => $definition->isShared(),
|
||||||
'abstract' => $definition->isAbstract(),
|
'abstract' => $definition->isAbstract(),
|
||||||
'autowire' => $definition->isAutowired(),
|
'autowire' => $definition->isAutowired(),
|
||||||
'autowiring_types' => array(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($definition->getAutowiringTypes() as $autowiringType) {
|
foreach ($definition->getAutowiringTypes(false) as $autowiringType) {
|
||||||
$data['autowiring_types'][] = $autowiringType;
|
$data['autowiring_types'][] = $autowiringType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,8 +185,8 @@ class MarkdownDescriptor extends Descriptor
|
|||||||
."\n".'- Autowired: '.($definition->isAutowired() ? 'yes' : 'no')
|
."\n".'- Autowired: '.($definition->isAutowired() ? 'yes' : 'no')
|
||||||
;
|
;
|
||||||
|
|
||||||
foreach ($definition->getAutowiringTypes() as $autowiringType) {
|
foreach ($definition->getAutowiringTypes(false) as $autowiringType) {
|
||||||
$output .= "\n" . '- Autowiring Type: `' . $autowiringType . '`';
|
$output .= "\n".'- Autowiring Type: `'.$autowiringType.'`';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['show_arguments']) && $options['show_arguments']) {
|
if (isset($options['show_arguments']) && $options['show_arguments']) {
|
||||||
|
@ -294,8 +294,9 @@ class TextDescriptor extends Descriptor
|
|||||||
$tableRows[] = array('Abstract', $definition->isAbstract() ? 'yes' : 'no');
|
$tableRows[] = array('Abstract', $definition->isAbstract() ? 'yes' : 'no');
|
||||||
$tableRows[] = array('Autowired', $definition->isAutowired() ? 'yes' : 'no');
|
$tableRows[] = array('Autowired', $definition->isAutowired() ? 'yes' : 'no');
|
||||||
|
|
||||||
$autowiringTypes = $definition->getAutowiringTypes();
|
if ($autowiringTypes = $definition->getAutowiringTypes(false)) {
|
||||||
$tableRows[] = array('Autowiring Types', $autowiringTypes ? implode(', ', $autowiringTypes) : '-');
|
$tableRows[] = array('Autowiring Types', implode(', ', $autowiringTypes));
|
||||||
|
}
|
||||||
|
|
||||||
if ($definition->getFile()) {
|
if ($definition->getFile()) {
|
||||||
$tableRows[] = array('Required File', $definition->getFile() ? $definition->getFile() : '-');
|
$tableRows[] = array('Required File', $definition->getFile() ? $definition->getFile() : '-');
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
|
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\Alias;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||||
use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface;
|
use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface;
|
||||||
@ -25,8 +26,8 @@ class TemplatingPass implements CompilerPassInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($container->hasAlias('templating')) {
|
if ($container->hasAlias('templating')) {
|
||||||
$definition = $container->findDefinition('templating');
|
$container->setAlias(ComponentEngineInterface::class, new Alias('templating', false));
|
||||||
$definition->setAutowiringTypes(array(ComponentEngineInterface::class, FrameworkBundleEngineInterface::class));
|
$container->setAlias(FrameworkBundleEngineInterface::class, new Alias('templating', false));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($container->hasDefinition('templating.engine.php')) {
|
if ($container->hasDefinition('templating.engine.php')) {
|
||||||
|
@ -1096,8 +1096,8 @@ class FrameworkExtension extends Extension
|
|||||||
->getDefinition('annotations.cached_reader')
|
->getDefinition('annotations.cached_reader')
|
||||||
->replaceArgument(1, new Reference($cacheService))
|
->replaceArgument(1, new Reference($cacheService))
|
||||||
->replaceArgument(2, $config['debug'])
|
->replaceArgument(2, $config['debug'])
|
||||||
->addAutowiringType(Reader::class)
|
|
||||||
;
|
;
|
||||||
|
$container->setAlias(Reader::class, new Alias('annotations.cached_reader', false));
|
||||||
} else {
|
} else {
|
||||||
$container->removeDefinition('annotations.cached_reader');
|
$container->removeDefinition('annotations.cached_reader');
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,8 @@
|
|||||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||||
|
|
||||||
<services>
|
<services>
|
||||||
<service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader" public="false">
|
<service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader" public="false" />
|
||||||
<autowiring-type>Doctrine\Common\Annotations\Reader</autowiring-type>
|
<service id="Doctrine\Common\Annotations\Reader" alias="annotations.reader" public="false" />
|
||||||
</service>
|
|
||||||
|
|
||||||
<service id="annotations.cached_reader" class="Doctrine\Common\Annotations\CachedReader" public="false">
|
<service id="annotations.cached_reader" class="Doctrine\Common\Annotations\CachedReader" public="false">
|
||||||
<argument type="service" id="annotations.reader" />
|
<argument type="service" id="annotations.reader" />
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
<services>
|
<services>
|
||||||
<service id="event_dispatcher" class="Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher">
|
<service id="event_dispatcher" class="Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher">
|
||||||
<argument type="service" id="service_container" />
|
<argument type="service" id="service_container" />
|
||||||
<autowiring-type>Symfony\Component\EventDispatcher\EventDispatcherInterface</autowiring-type>
|
|
||||||
<autowiring-type>Symfony\Component\EventDispatcher\EventDispatcher</autowiring-type>
|
|
||||||
</service>
|
</service>
|
||||||
|
<service id="Symfony\Component\EventDispatcher\EventDispatcherInterface" alias="event_dispatcher" public="false" />
|
||||||
|
<service id="Symfony\Component\EventDispatcher\EventDispatcher" alias="event_dispatcher" public="false" />
|
||||||
|
|
||||||
<service id="http_kernel" class="Symfony\Component\HttpKernel\HttpKernel">
|
<service id="http_kernel" class="Symfony\Component\HttpKernel\HttpKernel">
|
||||||
<argument type="service" id="event_dispatcher" />
|
<argument type="service" id="event_dispatcher" />
|
||||||
@ -40,10 +40,8 @@
|
|||||||
<argument type="collection" />
|
<argument type="collection" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="service_container" synthetic="true">
|
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false" />
|
||||||
<autowiring-type>Symfony\Component\DependencyInjection\ContainerInterface</autowiring-type>
|
<service id="Symfony\Component\DependencyInjection\Container" alias="service_container" public="false" />
|
||||||
<autowiring-type>Symfony\Component\DependencyInjection\Container</autowiring-type>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service id="kernel" synthetic="true" />
|
<service id="kernel" synthetic="true" />
|
||||||
|
|
||||||
|
@ -17,9 +17,8 @@
|
|||||||
<call method="setConfigCacheFactory">
|
<call method="setConfigCacheFactory">
|
||||||
<argument type="service" id="config_cache_factory" />
|
<argument type="service" id="config_cache_factory" />
|
||||||
</call>
|
</call>
|
||||||
|
|
||||||
<autowiring-type>Symfony\Component\Translation\TranslatorInterface</autowiring-type>
|
|
||||||
</service>
|
</service>
|
||||||
|
<service id="Symfony\Component\Translation\TranslatorInterface" alias="translator" public="false" />
|
||||||
|
|
||||||
<service id="translator.logging" class="Symfony\Component\Translation\LoggingTranslator" public="false">
|
<service id="translator.logging" class="Symfony\Component\Translation\LoggingTranslator" public="false">
|
||||||
<argument type="service" id="translator.logging.inner" />
|
<argument type="service" id="translator.logging.inner" />
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
"shared": true,
|
"shared": true,
|
||||||
"abstract": true,
|
"abstract": true,
|
||||||
"autowire": false,
|
"autowire": false,
|
||||||
"autowiring_types": [],
|
|
||||||
"file": null,
|
"file": null,
|
||||||
"factory_class": "Full\\Qualified\\FactoryClass",
|
"factory_class": "Full\\Qualified\\FactoryClass",
|
||||||
"factory_method": "get",
|
"factory_method": "get",
|
||||||
|
@ -3,19 +3,18 @@
|
|||||||
[33mInformation for Service "[39m[32mservice_1[39m[33m"[39m
|
[33mInformation for Service "[39m[32mservice_1[39m[33m"[39m
|
||||||
[33m===================================[39m
|
[33m===================================[39m
|
||||||
|
|
||||||
------------------ -----------------------------
|
---------------- -----------------------------
|
||||||
[32m Option [39m [32m Value [39m
|
[32m Option [39m [32m Value [39m
|
||||||
------------------ -----------------------------
|
---------------- -----------------------------
|
||||||
Service ID service_1
|
Service ID service_1
|
||||||
Class Full\Qualified\Class1
|
Class Full\Qualified\Class1
|
||||||
Tags -
|
Tags -
|
||||||
Public yes
|
Public yes
|
||||||
Synthetic no
|
Synthetic no
|
||||||
Lazy yes
|
Lazy yes
|
||||||
Shared yes
|
Shared yes
|
||||||
Abstract yes
|
Abstract yes
|
||||||
Autowired no
|
Autowired no
|
||||||
Autowiring Types -
|
Factory Class Full\Qualified\FactoryClass
|
||||||
Factory Class Full\Qualified\FactoryClass
|
Factory Method get
|
||||||
Factory Method get
|
---------------- -----------------------------
|
||||||
------------------ -----------------------------
|
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
"shared": true,
|
"shared": true,
|
||||||
"abstract": false,
|
"abstract": false,
|
||||||
"autowire": false,
|
"autowire": false,
|
||||||
"autowiring_types": [],
|
|
||||||
"file": "\/path\/to\/file",
|
"file": "\/path\/to\/file",
|
||||||
"factory_service": "factory.service",
|
"factory_service": "factory.service",
|
||||||
"factory_method": "get",
|
"factory_method": "get",
|
||||||
|
@ -3,23 +3,22 @@
|
|||||||
[33mInformation for Service "[39m[32mservice_2[39m[33m"[39m
|
[33mInformation for Service "[39m[32mservice_2[39m[33m"[39m
|
||||||
[33m===================================[39m
|
[33m===================================[39m
|
||||||
|
|
||||||
------------------ ---------------------------------
|
----------------- ---------------------------------
|
||||||
[32m Option [39m [32m Value [39m
|
[32m Option [39m [32m Value [39m
|
||||||
------------------ ---------------------------------
|
----------------- ---------------------------------
|
||||||
Service ID service_2
|
Service ID service_2
|
||||||
Class Full\Qualified\Class2
|
Class Full\Qualified\Class2
|
||||||
Tags tag1 ([32mattr1[39m: val1, [32mattr2[39m: val2)
|
Tags tag1 ([32mattr1[39m: val1, [32mattr2[39m: val2)
|
||||||
tag1 ([32mattr3[39m: val3)
|
tag1 ([32mattr3[39m: val3)
|
||||||
tag2
|
tag2
|
||||||
Calls setMailer
|
Calls setMailer
|
||||||
Public no
|
Public no
|
||||||
Synthetic yes
|
Synthetic yes
|
||||||
Lazy no
|
Lazy no
|
||||||
Shared yes
|
Shared yes
|
||||||
Abstract no
|
Abstract no
|
||||||
Autowired no
|
Autowired no
|
||||||
Autowiring Types -
|
Required File /path/to/file
|
||||||
Required File /path/to/file
|
Factory Service factory.service
|
||||||
Factory Service factory.service
|
Factory Method get
|
||||||
Factory Method get
|
----------------- ---------------------------------
|
||||||
------------------ ---------------------------------
|
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
],
|
],
|
||||||
"autowire": false,
|
"autowire": false,
|
||||||
"autowiring_types": [],
|
|
||||||
"arguments": [
|
"arguments": [
|
||||||
{
|
{
|
||||||
"type": "service",
|
"type": "service",
|
||||||
@ -29,7 +28,6 @@
|
|||||||
"shared": true,
|
"shared": true,
|
||||||
"abstract": false,
|
"abstract": false,
|
||||||
"autowire": false,
|
"autowire": false,
|
||||||
"autowiring_types": [],
|
|
||||||
"arguments": [
|
"arguments": [
|
||||||
"arg1",
|
"arg1",
|
||||||
"arg2"
|
"arg2"
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
"tags": [
|
"tags": [
|
||||||
|
|
||||||
],
|
],
|
||||||
"autowire": false,
|
"autowire": false
|
||||||
"autowiring_types": []
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"aliases": {
|
"aliases": {
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
"tags": [
|
"tags": [
|
||||||
|
|
||||||
],
|
],
|
||||||
"autowire": false,
|
"autowire": false
|
||||||
"autowiring_types": []
|
|
||||||
},
|
},
|
||||||
"definition_2": {
|
"definition_2": {
|
||||||
"class": "Full\\Qualified\\Class2",
|
"class": "Full\\Qualified\\Class2",
|
||||||
@ -50,8 +49,7 @@
|
|||||||
"calls": [
|
"calls": [
|
||||||
"setMailer"
|
"setMailer"
|
||||||
],
|
],
|
||||||
"autowire": false,
|
"autowire": false
|
||||||
"autowiring_types": []
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"aliases": {
|
"aliases": {
|
||||||
|
@ -34,8 +34,7 @@
|
|||||||
"calls": [
|
"calls": [
|
||||||
"setMailer"
|
"setMailer"
|
||||||
],
|
],
|
||||||
"autowire": false,
|
"autowire": false
|
||||||
"autowiring_types": []
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"aliases": [
|
"aliases": [
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
],
|
],
|
||||||
"factory_service": "factory.service",
|
"factory_service": "factory.service",
|
||||||
"factory_method": "get",
|
"factory_method": "get",
|
||||||
"autowire": false,
|
"autowire": false
|
||||||
"autowiring_types": []
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"tag2": [
|
"tag2": [
|
||||||
@ -31,8 +30,7 @@
|
|||||||
],
|
],
|
||||||
"factory_service": "factory.service",
|
"factory_service": "factory.service",
|
||||||
"factory_method": "get",
|
"factory_method": "get",
|
||||||
"autowire": false,
|
"autowire": false
|
||||||
"autowiring_types": []
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,5 @@
|
|||||||
"tags": [
|
"tags": [
|
||||||
|
|
||||||
],
|
],
|
||||||
"autowire": false,
|
"autowire": false
|
||||||
"autowiring_types": []
|
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
------------------ -----------------------------
|
---------------- -----------------------------
|
||||||
[32m Option [39m [32m Value [39m
|
[32m Option [39m [32m Value [39m
|
||||||
------------------ -----------------------------
|
---------------- -----------------------------
|
||||||
Service ID -
|
Service ID -
|
||||||
Class Full\Qualified\Class1
|
Class Full\Qualified\Class1
|
||||||
Tags -
|
Tags -
|
||||||
Public yes
|
Public yes
|
||||||
Synthetic no
|
Synthetic no
|
||||||
Lazy yes
|
Lazy yes
|
||||||
Shared yes
|
Shared yes
|
||||||
Abstract yes
|
Abstract yes
|
||||||
Autowired no
|
Autowired no
|
||||||
Autowiring Types -
|
Factory Class Full\Qualified\FactoryClass
|
||||||
Factory Class Full\Qualified\FactoryClass
|
Factory Method get
|
||||||
Factory Method get
|
---------------- -----------------------------
|
||||||
------------------ -----------------------------
|
|
||||||
|
|
||||||
|
@ -32,6 +32,5 @@
|
|||||||
"calls": [
|
"calls": [
|
||||||
"setMailer"
|
"setMailer"
|
||||||
],
|
],
|
||||||
"autowire": false,
|
"autowire": false
|
||||||
"autowiring_types": []
|
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
------------------ ---------------------------------
|
----------------- ---------------------------------
|
||||||
[32m Option [39m [32m Value [39m
|
[32m Option [39m [32m Value [39m
|
||||||
------------------ ---------------------------------
|
----------------- ---------------------------------
|
||||||
Service ID -
|
Service ID -
|
||||||
Class Full\Qualified\Class2
|
Class Full\Qualified\Class2
|
||||||
Tags tag1 ([32mattr1[39m: val1, [32mattr2[39m: val2)
|
Tags tag1 ([32mattr1[39m: val1, [32mattr2[39m: val2)
|
||||||
tag1 ([32mattr3[39m: val3)
|
tag1 ([32mattr3[39m: val3)
|
||||||
tag2
|
tag2
|
||||||
Calls setMailer
|
Calls setMailer
|
||||||
Public no
|
Public no
|
||||||
Synthetic yes
|
Synthetic yes
|
||||||
Lazy no
|
Lazy no
|
||||||
Shared yes
|
Shared yes
|
||||||
Abstract no
|
Abstract no
|
||||||
Autowired no
|
Autowired no
|
||||||
Autowiring Types -
|
Required File /path/to/file
|
||||||
Required File /path/to/file
|
Factory Service factory.service
|
||||||
Factory Service factory.service
|
Factory Method get
|
||||||
Factory Method get
|
----------------- ---------------------------------
|
||||||
------------------ ---------------------------------
|
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
"shared": true,
|
"shared": true,
|
||||||
"abstract": true,
|
"abstract": true,
|
||||||
"autowire": false,
|
"autowire": false,
|
||||||
"autowiring_types": [],
|
|
||||||
"arguments": [
|
"arguments": [
|
||||||
{
|
{
|
||||||
"type": "service",
|
"type": "service",
|
||||||
@ -21,7 +20,6 @@
|
|||||||
"shared": true,
|
"shared": true,
|
||||||
"abstract": false,
|
"abstract": false,
|
||||||
"autowire": false,
|
"autowire": false,
|
||||||
"autowiring_types": [],
|
|
||||||
"arguments": [
|
"arguments": [
|
||||||
"arg1",
|
"arg1",
|
||||||
"arg2"
|
"arg2"
|
||||||
|
@ -1,20 +1,19 @@
|
|||||||
------------------ -----------------------------
|
---------------- -----------------------------
|
||||||
[32m Option [39m [32m Value [39m
|
[32m Option [39m [32m Value [39m
|
||||||
------------------ -----------------------------
|
---------------- -----------------------------
|
||||||
Service ID -
|
Service ID -
|
||||||
Class Full\Qualified\Class1
|
Class Full\Qualified\Class1
|
||||||
Tags -
|
Tags -
|
||||||
Public yes
|
Public yes
|
||||||
Synthetic no
|
Synthetic no
|
||||||
Lazy yes
|
Lazy yes
|
||||||
Shared yes
|
Shared yes
|
||||||
Abstract yes
|
Abstract yes
|
||||||
Autowired no
|
Autowired no
|
||||||
Autowiring Types -
|
Factory Class Full\Qualified\FactoryClass
|
||||||
Factory Class Full\Qualified\FactoryClass
|
Factory Method get
|
||||||
Factory Method get
|
Arguments Service(definition2)
|
||||||
Arguments Service(definition2)
|
%parameter%
|
||||||
%parameter%
|
Inlined Service
|
||||||
Inlined Service
|
---------------- -----------------------------
|
||||||
------------------ -----------------------------
|
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
"shared": true,
|
"shared": true,
|
||||||
"abstract": false,
|
"abstract": false,
|
||||||
"autowire": false,
|
"autowire": false,
|
||||||
"autowiring_types": [],
|
|
||||||
"arguments": [],
|
"arguments": [],
|
||||||
"file": "\/path\/to\/file",
|
"file": "\/path\/to\/file",
|
||||||
"factory_service": "factory.service",
|
"factory_service": "factory.service",
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
------------------ ---------------------------------
|
----------------- ---------------------------------
|
||||||
[32m Option [39m [32m Value [39m
|
[32m Option [39m [32m Value [39m
|
||||||
------------------ ---------------------------------
|
----------------- ---------------------------------
|
||||||
Service ID -
|
Service ID -
|
||||||
Class Full\Qualified\Class2
|
Class Full\Qualified\Class2
|
||||||
Tags tag1 ([32mattr1[39m: val1, [32mattr2[39m: val2)
|
Tags tag1 ([32mattr1[39m: val1, [32mattr2[39m: val2)
|
||||||
tag1 ([32mattr3[39m: val3)
|
tag1 ([32mattr3[39m: val3)
|
||||||
tag2
|
tag2
|
||||||
Calls setMailer
|
Calls setMailer
|
||||||
Public no
|
Public no
|
||||||
Synthetic yes
|
Synthetic yes
|
||||||
Lazy no
|
Lazy no
|
||||||
Shared yes
|
Shared yes
|
||||||
Abstract no
|
Abstract no
|
||||||
Autowired no
|
Autowired no
|
||||||
Autowiring Types -
|
Required File /path/to/file
|
||||||
Required File /path/to/file
|
Factory Service factory.service
|
||||||
Factory Service factory.service
|
Factory Method get
|
||||||
Factory Method get
|
----------------- ---------------------------------
|
||||||
------------------ ---------------------------------
|
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ CHANGELOG
|
|||||||
3.3.0
|
3.3.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
* deprecated autowiring-types, use aliases instead
|
||||||
* [EXPERIMENTAL] added support for getter-injection
|
* [EXPERIMENTAL] added support for getter-injection
|
||||||
* added support for omitting the factory class name in a service definition if the definition class is set
|
* added support for omitting the factory class name in a service definition if the definition class is set
|
||||||
* deprecated case insensitivity of service identifiers
|
* deprecated case insensitivity of service identifiers
|
||||||
|
@ -245,6 +245,13 @@ class AutowirePass extends AbstractRecursivePass
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->container->has($typeName) && !$this->container->findDefinition($typeName)->isAbstract()) {
|
||||||
|
$arguments[$index] = new Reference($typeName);
|
||||||
|
$didAutowire = true;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (null === $this->types) {
|
if (null === $this->types) {
|
||||||
$this->populateAvailableTypes();
|
$this->populateAvailableTypes();
|
||||||
}
|
}
|
||||||
@ -332,7 +339,7 @@ class AutowirePass extends AbstractRecursivePass
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($definition->getAutowiringTypes() as $type) {
|
foreach ($definition->getAutowiringTypes(false) as $type) {
|
||||||
$this->definedTypes[$type] = true;
|
$this->definedTypes[$type] = true;
|
||||||
$this->types[$type] = $id;
|
$this->types[$type] = $id;
|
||||||
}
|
}
|
||||||
|
@ -53,11 +53,15 @@ class DecoratorServicePass implements CompilerPassInterface
|
|||||||
} else {
|
} else {
|
||||||
$decoratedDefinition = $container->getDefinition($inner);
|
$decoratedDefinition = $container->getDefinition($inner);
|
||||||
$definition->setTags(array_merge($decoratedDefinition->getTags(), $definition->getTags()));
|
$definition->setTags(array_merge($decoratedDefinition->getTags(), $definition->getTags()));
|
||||||
$definition->setAutowiringTypes(array_merge($decoratedDefinition->getAutowiringTypes(), $definition->getAutowiringTypes()));
|
if ($types = array_merge($decoratedDefinition->getAutowiringTypes(false), $definition->getAutowiringTypes(false))) {
|
||||||
|
$definition->setAutowiringTypes($types);
|
||||||
|
}
|
||||||
$public = $decoratedDefinition->isPublic();
|
$public = $decoratedDefinition->isPublic();
|
||||||
$decoratedDefinition->setPublic(false);
|
$decoratedDefinition->setPublic(false);
|
||||||
$decoratedDefinition->setTags(array());
|
$decoratedDefinition->setTags(array());
|
||||||
$decoratedDefinition->setAutowiringTypes(array());
|
if ($decoratedDefinition->getAutowiringTypes(false)) {
|
||||||
|
$decoratedDefinition->setAutowiringTypes(array());
|
||||||
|
}
|
||||||
$container->setDefinition($renamedId, $decoratedDefinition);
|
$container->setDefinition($renamedId, $decoratedDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,9 +53,9 @@ class PassConfig
|
|||||||
new ResolveFactoryClassPass(),
|
new ResolveFactoryClassPass(),
|
||||||
new FactoryReturnTypePass($resolveClassPass),
|
new FactoryReturnTypePass($resolveClassPass),
|
||||||
new CheckDefinitionValidityPass(),
|
new CheckDefinitionValidityPass(),
|
||||||
|
new AutowirePass(),
|
||||||
new ResolveReferencesToAliasesPass(),
|
new ResolveReferencesToAliasesPass(),
|
||||||
new ResolveInvalidReferencesPass(),
|
new ResolveInvalidReferencesPass(),
|
||||||
new AutowirePass(),
|
|
||||||
new AnalyzeServiceReferencesPass(true),
|
new AnalyzeServiceReferencesPass(true),
|
||||||
new CheckCircularReferencesPass(),
|
new CheckCircularReferencesPass(),
|
||||||
new CheckReferenceValidityPass(),
|
new CheckReferenceValidityPass(),
|
||||||
|
@ -90,7 +90,9 @@ class ResolveDefinitionTemplatesPass extends AbstractRecursivePass
|
|||||||
$def->setMethodCalls($parentDef->getMethodCalls());
|
$def->setMethodCalls($parentDef->getMethodCalls());
|
||||||
$def->setOverriddenGetters($parentDef->getOverriddenGetters());
|
$def->setOverriddenGetters($parentDef->getOverriddenGetters());
|
||||||
$def->setProperties($parentDef->getProperties());
|
$def->setProperties($parentDef->getProperties());
|
||||||
$def->setAutowiringTypes($parentDef->getAutowiringTypes());
|
if ($parentDef->getAutowiringTypes(false)) {
|
||||||
|
$def->setAutowiringTypes($parentDef->getAutowiringTypes(false));
|
||||||
|
}
|
||||||
if ($parentDef->isDeprecated()) {
|
if ($parentDef->isDeprecated()) {
|
||||||
$def->setDeprecated(true, $parentDef->getDeprecationMessage('%service_id%'));
|
$def->setDeprecated(true, $parentDef->getDeprecationMessage('%service_id%'));
|
||||||
}
|
}
|
||||||
@ -167,7 +169,7 @@ class ResolveDefinitionTemplatesPass extends AbstractRecursivePass
|
|||||||
}
|
}
|
||||||
|
|
||||||
// merge autowiring types
|
// merge autowiring types
|
||||||
foreach ($definition->getAutowiringTypes() as $autowiringType) {
|
foreach ($definition->getAutowiringTypes(false) as $autowiringType) {
|
||||||
$def->addAutowiringType($autowiringType);
|
$def->addAutowiringType($autowiringType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -679,9 +679,13 @@ class Definition
|
|||||||
* @param string[] $types
|
* @param string[] $types
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
|
*
|
||||||
|
* @deprecated since version 3.3, to be removed in 4.0.
|
||||||
*/
|
*/
|
||||||
public function setAutowiringTypes(array $types)
|
public function setAutowiringTypes(array $types)
|
||||||
{
|
{
|
||||||
|
@trigger_error('Autowiring-types are deprecated since Symfony 3.3 and will be removed in 4.0. Use aliases instead.', E_USER_DEPRECATED);
|
||||||
|
|
||||||
$this->autowiringTypes = array();
|
$this->autowiringTypes = array();
|
||||||
|
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
@ -750,9 +754,15 @@ class Definition
|
|||||||
* Gets autowiring types that will default to this definition.
|
* Gets autowiring types that will default to this definition.
|
||||||
*
|
*
|
||||||
* @return string[]
|
* @return string[]
|
||||||
|
*
|
||||||
|
* @deprecated since version 3.3, to be removed in 4.0.
|
||||||
*/
|
*/
|
||||||
public function getAutowiringTypes()
|
public function getAutowiringTypes(/*$triggerDeprecation = true*/)
|
||||||
{
|
{
|
||||||
|
if (1 > func_num_args() || func_get_arg(0)) {
|
||||||
|
@trigger_error('Autowiring-types are deprecated since Symfony 3.3 and will be removed in 4.0. Use aliases instead.', E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
return array_keys($this->autowiringTypes);
|
return array_keys($this->autowiringTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -762,9 +772,13 @@ class Definition
|
|||||||
* @param string $type
|
* @param string $type
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
|
*
|
||||||
|
* @deprecated since version 3.3, to be removed in 4.0.
|
||||||
*/
|
*/
|
||||||
public function addAutowiringType($type)
|
public function addAutowiringType($type)
|
||||||
{
|
{
|
||||||
|
@trigger_error(sprintf('Autowiring-types are deprecated since Symfony 3.3 and will be removed in 4.0. Use aliases instead for "%s".', $type), E_USER_DEPRECATED);
|
||||||
|
|
||||||
$this->autowiringTypes[$type] = true;
|
$this->autowiringTypes[$type] = true;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -776,9 +790,13 @@ class Definition
|
|||||||
* @param string $type
|
* @param string $type
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
|
*
|
||||||
|
* @deprecated since version 3.3, to be removed in 4.0.
|
||||||
*/
|
*/
|
||||||
public function removeAutowiringType($type)
|
public function removeAutowiringType($type)
|
||||||
{
|
{
|
||||||
|
@trigger_error(sprintf('Autowiring-types are deprecated since Symfony 3.3 and will be removed in 4.0. Use aliases instead for "%s".', $type), E_USER_DEPRECATED);
|
||||||
|
|
||||||
unset($this->autowiringTypes[$type]);
|
unset($this->autowiringTypes[$type]);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -790,9 +808,13 @@ class Definition
|
|||||||
* @param string $type
|
* @param string $type
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
|
*
|
||||||
|
* @deprecated since version 3.3, to be removed in 4.0.
|
||||||
*/
|
*/
|
||||||
public function hasAutowiringType($type)
|
public function hasAutowiringType($type)
|
||||||
{
|
{
|
||||||
|
@trigger_error(sprintf('Autowiring-types are deprecated since Symfony 3.3 and will be removed in 4.0. Use aliases instead for "%s".', $type), E_USER_DEPRECATED);
|
||||||
|
|
||||||
return isset($this->autowiringTypes[$type]);
|
return isset($this->autowiringTypes[$type]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ class XmlDumper extends Dumper
|
|||||||
$service->setAttribute('autowire', 'true');
|
$service->setAttribute('autowire', 'true');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($definition->getAutowiringTypes() as $autowiringTypeValue) {
|
foreach ($definition->getAutowiringTypes(false) as $autowiringTypeValue) {
|
||||||
$autowiringType = $this->document->createElement('autowiring-type');
|
$autowiringType = $this->document->createElement('autowiring-type');
|
||||||
$autowiringType->appendChild($this->document->createTextNode($autowiringTypeValue));
|
$autowiringType->appendChild($this->document->createTextNode($autowiringTypeValue));
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class YamlDumper extends Dumper
|
|||||||
}
|
}
|
||||||
|
|
||||||
$autowiringTypesCode = '';
|
$autowiringTypesCode = '';
|
||||||
foreach ($definition->getAutowiringTypes() as $autowiringType) {
|
foreach ($definition->getAutowiringTypes(false) as $autowiringType) {
|
||||||
$autowiringTypesCode .= sprintf(" - %s\n", $this->dumper->dump($autowiringType));
|
$autowiringTypesCode .= sprintf(" - %s\n", $this->dumper->dump($autowiringType));
|
||||||
}
|
}
|
||||||
if ($autowiringTypesCode) {
|
if ($autowiringTypesCode) {
|
||||||
|
@ -191,7 +191,7 @@ class AutowirePassTest extends \PHPUnit_Framework_TestCase
|
|||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
|
||||||
$container->register('a1', __NAMESPACE__.'\Foo');
|
$container->register('a1', __NAMESPACE__.'\Foo');
|
||||||
$container->register('a2', __NAMESPACE__.'\Foo')->addAutowiringType(__NAMESPACE__.'\Foo');
|
$container->register(Foo::class, Foo::class);
|
||||||
$aDefinition = $container->register('a', __NAMESPACE__.'\NotGuessableArgument');
|
$aDefinition = $container->register('a', __NAMESPACE__.'\NotGuessableArgument');
|
||||||
$aDefinition->setAutowired(true);
|
$aDefinition->setAutowired(true);
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ class AutowirePassTest extends \PHPUnit_Framework_TestCase
|
|||||||
$pass->process($container);
|
$pass->process($container);
|
||||||
|
|
||||||
$this->assertCount(1, $container->getDefinition('a')->getArguments());
|
$this->assertCount(1, $container->getDefinition('a')->getArguments());
|
||||||
$this->assertEquals('a2', (string) $container->getDefinition('a')->getArgument(0));
|
$this->assertEquals(Foo::class, (string) $container->getDefinition('a')->getArgument(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWithTypeSet()
|
public function testWithTypeSet()
|
||||||
@ -207,7 +207,8 @@ class AutowirePassTest extends \PHPUnit_Framework_TestCase
|
|||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
|
||||||
$container->register('c1', __NAMESPACE__.'\CollisionA');
|
$container->register('c1', __NAMESPACE__.'\CollisionA');
|
||||||
$container->register('c2', __NAMESPACE__.'\CollisionB')->addAutowiringType(__NAMESPACE__.'\CollisionInterface');
|
$container->register('c2', __NAMESPACE__.'\CollisionB');
|
||||||
|
$container->setAlias(CollisionInterface::class, 'c2');
|
||||||
$aDefinition = $container->register('a', __NAMESPACE__.'\CannotBeAutowired');
|
$aDefinition = $container->register('a', __NAMESPACE__.'\CannotBeAutowired');
|
||||||
$aDefinition->setAutowired(true);
|
$aDefinition->setAutowired(true);
|
||||||
|
|
||||||
@ -215,7 +216,7 @@ class AutowirePassTest extends \PHPUnit_Framework_TestCase
|
|||||||
$pass->process($container);
|
$pass->process($container);
|
||||||
|
|
||||||
$this->assertCount(1, $container->getDefinition('a')->getArguments());
|
$this->assertCount(1, $container->getDefinition('a')->getArguments());
|
||||||
$this->assertEquals('c2', (string) $container->getDefinition('a')->getArgument(0));
|
$this->assertEquals(CollisionInterface::class, (string) $container->getDefinition('a')->getArgument(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateDefinition()
|
public function testCreateDefinition()
|
||||||
|
@ -143,6 +143,9 @@ class DecoratorServicePassTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals(array('bar' => array('attr' => 'baz'), 'foobar' => array('attr' => 'bar')), $container->getDefinition('baz')->getTags());
|
$this->assertEquals(array('bar' => array('attr' => 'baz'), 'foobar' => array('attr' => 'bar')), $container->getDefinition('baz')->getTags());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
public function testProcessMergesAutowiringTypesInDecoratingDefinitionAndRemoveThemFromDecoratedDefinition()
|
public function testProcessMergesAutowiringTypesInDecoratingDefinitionAndRemoveThemFromDecoratedDefinition()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
@ -322,6 +322,9 @@ class ResolveDefinitionTemplatesPassTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertFalse($container->getDefinition('decorated_deprecated_parent')->isDeprecated());
|
$this->assertFalse($container->getDefinition('decorated_deprecated_parent')->isDeprecated());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
public function testProcessMergeAutowiringTypes()
|
public function testProcessMergeAutowiringTypes()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
@ -313,6 +313,9 @@ class DefinitionTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertTrue($def->isAutowired());
|
$this->assertTrue($def->isAutowired());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
public function testTypes()
|
public function testTypes()
|
||||||
{
|
{
|
||||||
$def = new Definition('stdClass');
|
$def = new Definition('stdClass');
|
||||||
|
@ -7,8 +7,6 @@ $container = new ContainerBuilder();
|
|||||||
$container
|
$container
|
||||||
->register('foo', 'Foo')
|
->register('foo', 'Foo')
|
||||||
->setAutowired(true)
|
->setAutowired(true)
|
||||||
->addAutowiringType('A')
|
|
||||||
->addAutowiringType('B')
|
|
||||||
;
|
;
|
||||||
|
|
||||||
return $container;
|
return $container;
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||||
<services>
|
<services>
|
||||||
<service id="foo" class="Foo" autowire="true">
|
<service id="foo" class="Foo" autowire="true"/>
|
||||||
<autowiring-type>A</autowiring-type>
|
|
||||||
<autowiring-type>B</autowiring-type>
|
|
||||||
</service>
|
|
||||||
</services>
|
</services>
|
||||||
</container>
|
</container>
|
||||||
|
@ -3,6 +3,3 @@ services:
|
|||||||
foo:
|
foo:
|
||||||
class: Foo
|
class: Foo
|
||||||
autowire: true
|
autowire: true
|
||||||
autowiring_types:
|
|
||||||
- A
|
|
||||||
- B
|
|
||||||
|
@ -554,6 +554,9 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertSame('configureBar', $barConfigurator[1]);
|
$this->assertSame('configureBar', $barConfigurator[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
public function testType()
|
public function testType()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
@ -325,6 +325,9 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$loader->load('bad_types2.yml');
|
$loader->load('bad_types2.yml');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
public function testTypes()
|
public function testTypes()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
Reference in New Issue
Block a user