Vinoteca: модуль, шаблон и компоненты интернет-магазина вина на 1С-Битрикс
This commit is contained in:
commit
bb7d8af290
469 files changed
+26426
No files matched your search
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Jinove\Vinoteca\Catalog;
|
||||
|
||||
use Jinove\Vinoteca\Config;
|
||||
use Jinove\Vinoteca\Cached;
|
||||
|
||||
class Countries
|
||||
{
|
||||
private const CACHE_TTL = 86400;
|
||||
private const CACHE_DIR = "/jinove.vinoteca/countries";
|
||||
|
||||
private static ?array $names = null;
|
||||
|
||||
public static function names(): array
|
||||
{
|
||||
if (self::$names !== null) {
|
||||
return self::$names;
|
||||
}
|
||||
$catalogId = Config::iblockId("catalog");
|
||||
return self::$names = (array)Cached::remember(self::CACHE_DIR, "names-" . $catalogId, self::CACHE_TTL, ["iblock_id_" . $catalogId], static function () use ($catalogId): array {
|
||||
$names = [];
|
||||
$rows = \CIBlockPropertyEnum::GetList(["SORT" => "ASC", "VALUE" => "ASC"], ["IBLOCK_ID" => $catalogId, "CODE" => "COUNTRY"]);
|
||||
while ($row = $rows->Fetch()) {
|
||||
$names[(string)$row["XML_ID"]] = (string)$row["VALUE"];
|
||||
}
|
||||
|
||||
return $names;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user