Skip to content

Commit c340d60

Browse files
committed
Allow the services to be reset by Symfony if people forget to do it manually
1 parent e98f137 commit c340d60

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"sylius/locale": "^1.0",
1616
"symfony/config": "^5.4 || ^6.4",
1717
"symfony/dependency-injection": "^5.4 || ^6.4",
18-
"symfony/http-kernel": "^5.4 || ^6.4"
18+
"symfony/http-kernel": "^5.4 || ^6.4",
19+
"symfony/service-contracts": "^1.1 || ^2.0 || ^3.0"
1920
},
2021
"require-dev": {
2122
"infection/infection": "^0.27.11",

src/Context/StaticChannelContext.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
use Sylius\Component\Channel\Context\ChannelNotFoundException;
99
use Sylius\Component\Channel\Model\ChannelInterface;
1010
use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
11+
use Symfony\Contracts\Service\ResetInterface;
1112

12-
final class StaticChannelContext implements ChannelContextInterface
13+
final class StaticChannelContext implements ChannelContextInterface, ResetInterface
1314
{
1415
private ?ChannelInterface $channel = null;
1516

@@ -43,4 +44,9 @@ public function setChannelCode(string $channelCode): void
4344

4445
$this->channel = $channel;
4546
}
47+
48+
public function reset(): void
49+
{
50+
$this->channel = null;
51+
}
4652
}

src/Context/StaticLocaleContext.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
use Sylius\Component\Locale\Context\LocaleContextInterface;
88
use Sylius\Component\Locale\Context\LocaleNotFoundException;
9+
use Symfony\Contracts\Service\ResetInterface;
910

10-
final class StaticLocaleContext implements LocaleContextInterface
11+
final class StaticLocaleContext implements LocaleContextInterface, ResetInterface
1112
{
1213
private ?string $localeCode = null;
1314

@@ -20,4 +21,9 @@ public function setLocaleCode(?string $localeCode): void
2021
{
2122
$this->localeCode = $localeCode;
2223
}
24+
25+
public function reset(): void
26+
{
27+
$this->localeCode = null;
28+
}
2329
}

0 commit comments

Comments
 (0)