Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
utils.php
1<?
2namespace Bitrix\Lists\Entity;
3
4class Utils
5{
13 public static function getIblockId(array $params)
14 {
15 if ($params["IBLOCK_ID"])
16 {
17 return (int) $params["IBLOCK_ID"];
18 }
19 elseif ($params["IBLOCK_CODE"] ?? null)
20 {
21 $queryObject = \CIBlock::getList([], [
22 "CHECK_PERMISSIONS" => "N",
23 "=CODE" => $params["IBLOCK_CODE"]
24 ]);
25 if ($iblock = $queryObject->fetch())
26 {
27 return (int) $iblock["ID"];
28 }
29 }
30
31 return 0;
32 }
33
41 public static function getElementId(array $params)
42 {
43 if ($params["ELEMENT_ID"])
44 {
45 return (int) $params["ELEMENT_ID"];
46 }
47 elseif ($params["ELEMENT_CODE"])
48 {
49 $queryObject = \CIBlockElement::getList([], [
50 "IBLOCK_ID" => Utils::getIblockId($params),
51 "CHECK_PERMISSIONS" => "N",
52 "=CODE" => $params["ELEMENT_CODE"],
53 ], false, false, ["ID"]);
54 if ($element = $queryObject->fetch())
55 {
56 return (int) $element["ID"];
57 }
58 }
59
60 return 0;
61 }
62
70 public static function getSectionId(array $params)
71 {
72 if ($params["SECTION_ID"])
73 {
74 return (int)$params["SECTION_ID"];
75 }
76 elseif ($params["SECTION_CODE"])
77 {
78 $queryObject = \CIBlockSection::getList([], [
79 "CHECK_PERMISSIONS" => "N",
80 "CODE" => $params["SECTION_CODE"]
81 ], false, false, ["ID"]);
82 if ($section = $queryObject->fetch())
83 {
84 return (int) $section["ID"];
85 }
86 }
87
88 return 0;
89 }
90}
static getSectionId(array $params)
Definition utils.php:70
static getIblockId(array $params)
Definition utils.php:13
static getElementId(array $params)
Definition utils.php:41