Vinoteca: модуль, шаблон и компоненты интернет-магазина вина на 1С-Битрикс

This commit is contained in:
jimagie committed 2026-10-22 03:32:28 +05:00
commit f6ba0d2174
470 files changed
+26454

No files matched your search

@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace Jinove\Vinoteca\Catalog;
use Bitrix\Main\Localization\Loc;
Loc::loadMessages(__FILE__);
class EnumNames
{
public static function name(string $propertyCode, string $xmlId, string $fallback = "", ?string $language = null): string
{
$key = "VINO_ENUM_" . $propertyCode . "_" . strtoupper(str_replace("-", "_", $xmlId));
$message = Loc::getMessage($key, null, $language);
return $message !== null && $message !== "" ? $message : $fallback;
}
public static function fromProperty(array $property): string
{
$xmlIds = (array)($property["VALUE_XML_ID"] ?? []);
$values = (array)($property["~VALUE"] ?? $property["VALUE"] ?? []);
$names = [];
foreach ($xmlIds as $index => $xmlId) {
if ((string)$xmlId === "") {
continue;
}
$names[] = self::name((string)$property["CODE"], (string)$xmlId, (string)($values[$index] ?? ""));
}
return implode(", ", $names);
}
}