/** * @param $iblockCode * @return Entity\DataManager * @throws ArgumentException */ public static function getInstance($iblockCode) { $iblock = IblockStructure::iblock($iblockCode); if (!$iblock) { throw new ArgumentException('Указан код несуществующего инфоблока'); } self::$iblockCode = $iblockCode; self::$iblockId = $iblock['ID']; return self::compileEntity(); }
/** * Метод инициализирует поиск данных, связанных с инфоблоками и начинает добавление свойств к списку возможных */ private function appendIblockRelatedData() { if ($this->searchIblocks()) { $maps = array(); if (empty($this->iblockPrimary)) { return $maps; } foreach ($this->iblockPrimary as $iblockPrimary) { $iblock = IblockStructure::iblock($iblockPrimary); $maps[] = ElementTable::getAdditionalMap($iblock['ID']); } call_user_func_array(array($this, 'appendIblockFields'), $maps); } }
/** * @param $iblockId * @return Entity\Base * @throws ArgumentException */ public static function compileEntity($iblockId) { $iblock = IblockStructure::iblock($iblockId); if (!$iblock) { throw new ArgumentException('Указан несуществующий идентификатор инфоблока'); } $entityName = "Iblock" . Entity\Base::snake2camel($iblockId) . "SectionTable"; $fullEntityName = '\\' . __NAMESPACE__ . '\\' . $entityName; $code = "\n namespace " . __NAMESPACE__ . ";\n class {$entityName} extends SectionTable {\n public static function getIblockId(){\n return {$iblock['ID']};\n }\n public static function getUfId(){\n return 'IBLOCK_{$iblock['ID']}_SECTION';\n }\n }\n "; if (!class_exists($fullEntityName)) { eval($code); } return Entity\Base::getInstance($fullEntityName); }