Skip to content

Commit 5fb9f3d

Browse files
committed
Make service not shared when prototype scope is set
1 parent 50e752b commit 5fb9f3d

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/Symfony/Component/DependencyInjection/Definition.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,10 @@ public function setScope($scope, $triggerDeprecationError = true)
649649
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
650650
}
651651

652+
if ('prototype' === $scope) {
653+
$this->setShared(false);
654+
}
655+
652656
$this->scope = $scope;
653657

654658
return $this;

src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/legacy-services9.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
<configurator class="%baz_class%" method="configureStatic1"/>
3434
</service>
3535
<service id="factory_service" class="Bar" factory-method="getInstance" factory-service="foo.baz"/>
36-
<service id="foo_bar" class="%foo_class%" scope="prototype"/>
36+
<service id="foo_bar" class="%foo_class%" shared="false" scope="prototype"/>
3737
</services>
3838
</container>

src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/legacy-services9.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ services:
2929
factory_service: foo.baz
3030
foo_bar:
3131
class: %foo_class%
32+
shared: false
3233
scope: prototype

0 commit comments

Comments
 (0)