/** * Fetches iblock metadata for further using. Uses cache. * Cache can be disabled with flag self::#cacheMetadata = false. * @param int|null $iblockId * @return array */ public static function getMetadata($iblockId = null) { if (empty($iblockId)) { $iblockId = static::$IBLOCK_ID; } \Bitrix\Main\Loader::includeModule('iblock'); $result = array(); $obCache = new \CPHPCache(); $cacheDir = '/' . $iblockId; if (static::$cacheMetadata && $obCache->InitCache(3600, 'iblockOrm', $cacheDir)) { $result = $obCache->GetVars(); } else { $result['iblock'] = \Bitrix\Iblock\IblockTable::getRowById($iblockId); $result['props'] = array(); $rs = \Bitrix\Iblock\PropertyTable::getList(array('filter' => array('IBLOCK_ID' => $iblockId))); while ($arProp = $rs->fetch()) { $result['props'][$arProp['CODE']] = $arProp; } if (static::$cacheMetadata) { $obCache->StartDataCache(); $obCache->EndDataCache($result); } } return $result; }