alex19pov31 /
bitrix-helper
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Alex19pov31\BitrixHelper; |
||
| 4 | |||
| 5 | use Bitrix\Iblock\IblockTable; |
||
|
0 ignored issues
–
show
|
|||
| 6 | |||
| 7 | class IblockHelper |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Список инфоблоков |
||
| 11 | * |
||
| 12 | * @var [type] |
||
|
0 ignored issues
–
show
|
|||
| 13 | */ |
||
| 14 | private static $iblockList; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Время кеширования |
||
| 18 | * |
||
| 19 | * @var integer |
||
| 20 | */ |
||
| 21 | private static $ttl = 0; |
||
| 22 | |||
| 23 | private static $iblockClass; |
||
| 24 | |||
| 25 | public static function setIBlockTableCalss(IblockTable $object) |
||
| 26 | { |
||
| 27 | static::$iblockClass = $object; |
||
|
0 ignored issues
–
show
|
|||
| 28 | } |
||
| 29 | |||
| 30 | private static function getIBlockTableClass() |
||
| 31 | { |
||
| 32 | if (!is_null(static::$iblockClass)) { |
||
|
0 ignored issues
–
show
|
|||
| 33 | return static::$iblockClass; |
||
| 34 | } |
||
| 35 | |||
| 36 | loadModule('iblock'); |
||
| 37 | return IblockTable::class; |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Список инфоблоков |
||
| 42 | * |
||
| 43 | * @return array |
||
| 44 | */ |
||
| 45 | public static function getListIblock(): array |
||
| 46 | { |
||
| 47 | if (!is_null(static::$iblockList)) { |
||
|
0 ignored issues
–
show
|
|||
| 48 | return (array)static::$iblockList; |
||
| 49 | } |
||
| 50 | |||
| 51 | $iblockTableClass = static::getIBlockTableClass(); |
||
| 52 | $res = $iblockTableClass::getList([ |
||
| 53 | 'select' => [ |
||
| 54 | 'ID', |
||
| 55 | 'IBLOCK_TYPE_ID', |
||
| 56 | 'CODE', |
||
| 57 | 'NAME', |
||
| 58 | ], |
||
| 59 | 'cache' => [ |
||
| 60 | 'ttl' => static::$ttl, |
||
|
0 ignored issues
–
show
|
|||
| 61 | ], |
||
| 62 | ]); |
||
| 63 | |||
| 64 | while ($iblock = $res->fetch()) { |
||
| 65 | static::$iblockList[$iblock['CODE']] = $iblock; |
||
| 66 | static::$iblockList[$iblock['CODE'] . '_' . $iblock['IBLOCK_TYPE_ID']] = $iblock; |
||
| 67 | } |
||
| 68 | |||
| 69 | return (array)static::$iblockList; |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Установить вермя кеширования |
||
| 74 | * |
||
| 75 | * @param integer $minutes |
||
| 76 | * @return void |
||
| 77 | */ |
||
| 78 | public static function setCacheTime(int $minutes) |
||
| 79 | { |
||
| 80 | static::$ttl = $minutes * 60; |
||
|
0 ignored issues
–
show
|
|||
| 81 | } |
||
| 82 | |||
| 83 | /** |
||
| 84 | * Возвращает идентификатор инфоблока по коду |
||
| 85 | * |
||
| 86 | * @param string $code |
||
| 87 | * @return integer|null |
||
| 88 | */ |
||
| 89 | public static function getIblockID(string $code, $iblockType = null) |
||
| 90 | { |
||
| 91 | $iblock = static::getIblock($code, $iblockType); |
||
| 92 | if (empty($iblock)) { |
||
| 93 | return null; |
||
| 94 | } |
||
| 95 | |||
| 96 | return (int)$iblock['ID']; |
||
| 97 | } |
||
| 98 | |||
| 99 | public static function getIblock(string $code, $iblockType = null) |
||
| 100 | { |
||
| 101 | $list = static::getListIblock(); |
||
| 102 | $key = is_null($iblockType) ? $code : $code . '_' . $iblockType; |
||
| 103 | $iblock = $list[$key]; |
||
| 104 | if (empty($iblock)) { |
||
| 105 | return null; |
||
| 106 | } |
||
| 107 | |||
| 108 | return (array)$iblock; |
||
| 109 | } |
||
| 110 | } |
||
| 111 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths