6 declare(strict_types=1);
28 private $enumDataMapper;
36 $this->typeConfig = $typeConfig;
37 $this->enumDataMapper = $enumDataMapper;
50 $priceViewEnum = $this->typeConfig->getConfigElement($enumName);
51 if ($priceViewEnum instanceof
Enum) {
52 foreach ($priceViewEnum->getValues() as $enumItem) {
53 $mappedValues = $this->enumDataMapper->getMappedEnums($enumName);
54 if (isset($mappedValues[$enumItem->getName()]) && $mappedValues[$enumItem->getName()] == $fieldValue) {
55 return $enumItem->getValue();
59 throw new \Magento\Framework\Exception\RuntimeException(
60 new Phrase(
'Enum type "%1" not defined', [$enumName])
getEnumValueFromField(string $enumName, string $fieldValue)
__construct(ConfigInterface $typeConfig, DataMapperInterface $enumDataMapper)