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

Skip to content

Commit 3b808b8

Browse files
committed
Fixed deprecated Intl component usage
1 parent c07b934 commit 3b808b8

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/Sylius/Bundle/CoreBundle/Form/Extension/LocaleTypeExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Symfony\Component\Form\FormBuilderInterface;
2121
use Symfony\Component\Form\FormEvent;
2222
use Symfony\Component\Form\FormEvents;
23-
use Symfony\Component\Intl\Intl;
23+
use Symfony\Component\Intl\Locales;
2424

2525
final class LocaleTypeExtension extends AbstractTypeExtension
2626
{
@@ -61,15 +61,15 @@ public function getExtendedType(): string
6161

6262
private function getLocaleName(string $code): ?string
6363
{
64-
return Intl::getLocaleBundle()->getLocaleName($code);
64+
return Locales::getName($code);
6565
}
6666

6767
/**
6868
* @return array|LocaleInterface[]
6969
*/
7070
private function getAvailableLocales(): array
7171
{
72-
$availableLocales = Intl::getLocaleBundle()->getLocaleNames();
72+
$availableLocales = Locales::getNames();
7373

7474
/** @var LocaleInterface[] $definedLocales */
7575
$definedLocales = $this->localeRepository->findAll();

src/Sylius/Component/Locale/Converter/LocaleConverter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414
namespace Sylius\Component\Locale\Converter;
1515

16-
use Symfony\Component\Intl\Intl;
16+
use Symfony\Component\Intl\Locales;
1717
use Webmozart\Assert\Assert;
1818

1919
final class LocaleConverter implements LocaleConverterInterface
2020
{
2121
public function convertNameToCode(string $name, ?string $locale = null): string
2222
{
23-
$names = Intl::getLocaleBundle()->getLocaleNames($locale ?? 'en');
23+
$names = Locales::getNames($locale ?? 'en');
2424
$code = array_search($name, $names, true);
2525

2626
Assert::string($code, sprintf('Cannot find code for "%s" locale name', $name));
@@ -30,7 +30,7 @@ public function convertNameToCode(string $name, ?string $locale = null): string
3030

3131
public function convertCodeToName(string $code, ?string $locale = null): string
3232
{
33-
$name = Intl::getLocaleBundle()->getLocaleName($code, $locale ?? 'en');
33+
$name = Locales::getName($code, $locale ?? 'en');
3434

3535
Assert::string($name, sprintf('Cannot find name for "%s" locale code', $code));
3636

src/Sylius/Component/Locale/Model/Locale.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace Sylius\Component\Locale\Model;
1515

1616
use Sylius\Component\Resource\Model\TimestampableTrait;
17-
use Symfony\Component\Intl\Intl;
17+
use Symfony\Component\Intl\Locales;
1818

1919
class Locale implements LocaleInterface
2020
{
@@ -53,6 +53,6 @@ public function setCode(?string $code): void
5353

5454
public function getName(?string $locale = null): ?string
5555
{
56-
return Intl::getLocaleBundle()->getLocaleName($this->getCode(), $locale);
56+
return Locales::getName($this->getCode(), $locale);
5757
}
5858
}

0 commit comments

Comments
 (0)