Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

LocaleConverter.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\MVC\Symfony\Locale;
8
9 use Psr\Log\LoggerInterface;
10
11 class LocaleConverter implements LocaleConverterInterface
12 {
19 private $conversionMap;
20
26 private $reverseConversionMap;
27
29 private $logger;
30
31 public function __construct(array $conversionMap, LoggerInterface $logger)
32 {
33 $this->conversionMap = $conversionMap;
34 $this->reverseConversionMap = array_flip($conversionMap);
35 $this->logger = $logger;
36 }
37
46 public function convertToPOSIX($ezpLocale)
47 {
48 if (!isset($this->conversionMap[$ezpLocale])) {
49 $this->logger->warning("Could not convert locale '$ezpLocale' to POSIX format. Please check your locale configuration in ezplatform.yml");
50
51 return;
52 }
53
54 return $this->conversionMap[$ezpLocale];
55 }
56
65 public function convertToEz($posixLocale)
66 {
67 if (!isset($this->reverseConversionMap[$posixLocale])) {
68 $this->logger->warning("Could not convert locale '$posixLocale' to eZ Publish format. Please check your locale configuration in ezplatform.yml");
69
70 return;
71 }
72
73 return $this->reverseConversionMap[$posixLocale];
74 }
75 }
eZ\Publish\Core\MVC\Symfony\Locale\LocaleConverter
Definition: LocaleConverter.php:12
eZ\Publish\Core\MVC\Symfony\Locale\LocaleConverter\$logger
$logger
Definition: LocaleConverter.php:29
eZ\Publish\Core\MVC\Symfony\Locale\LocaleConverter\$reverseConversionMap
$reverseConversionMap
Definition: LocaleConverter.php:26
eZ\Publish\Core\MVC\Symfony\Locale\LocaleConverter\__construct
__construct(array $conversionMap, LoggerInterface $logger)
Definition: LocaleConverter.php:31
eZ\Publish\Core\MVC\Symfony\Locale\LocaleConverter\convertToPOSIX
convertToPOSIX($ezpLocale)
Converts a locale in eZ Publish internal format to POSIX format.
Definition: LocaleConverter.php:46
eZ\Publish\Core\MVC\Symfony\Locale\LocaleConverter\$conversionMap
$conversionMap
Definition: LocaleConverter.php:19
eZ\Publish\Core\MVC\Symfony\Locale\LocaleConverter\convertToEz
convertToEz($posixLocale)
Converts a locale in POSIX format to eZ Publish internal format.
Definition: LocaleConverter.php:65
eZ\Publish\Core\MVC\Symfony\Locale\LocaleConverterInterface
Interface for locale converters.
Definition: LocaleConverterInterface.php:17
eZ\Publish\Core\MVC\Symfony\Locale
Definition: LocaleConverter.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.