136 'data_type' =>
'integer',
138 'autocomplete' =>
true,
141 'TIMESTAMP_X' => array(
142 'data_type' =>
'datetime',
145 'IBLOCK_TYPE_ID' => array(
146 'data_type' =>
'string',
149 'validation' => array(__CLASS__,
'validateIblockTypeId'),
152 'data_type' =>
'string',
153 'validation' => array(__CLASS__,
'validateLid'),
156 'data_type' =>
'string',
158 'validation' => array(__CLASS__,
'validateCode'),
163 ->configureValues(
'N',
'Y')
164 ->configureDefaultValue(
'N'),
166 'data_type' =>
'string',
169 'validation' => array(__CLASS__,
'validateName'),
172 'data_type' =>
'boolean',
173 'values' => array(
'N',
'Y'),
177 'data_type' =>
'integer',
180 'LIST_PAGE_URL' => array(
181 'data_type' =>
'string',
183 'validation' => array(__CLASS__,
'validateListPageUrl'),
185 'DETAIL_PAGE_URL' => array(
186 'data_type' =>
'string',
188 'validation' => array(__CLASS__,
'validateDetailPageUrl'),
190 'SECTION_PAGE_URL' => array(
191 'data_type' =>
'string',
193 'validation' => array(__CLASS__,
'validateSectionPageUrl'),
195 'CANONICAL_PAGE_URL' => array(
196 'data_type' =>
'string',
198 'validation' => array(__CLASS__,
'validateCanonicalPageUrl'),
201 'data_type' =>
'integer',
204 'DESCRIPTION' => array(
205 'data_type' =>
'string',
208 'DESCRIPTION_TYPE' => array(
209 'data_type' =>
'enum',
210 'values' => array(
'text',
'html'),
214 'data_type' =>
'string',
216 'validation' => array(__CLASS__,
'validateXmlId'),
219 'data_type' =>
'string',
221 'validation' => array(__CLASS__,
'validateTmpId'),
223 'INDEX_ELEMENT' => array(
224 'data_type' =>
'boolean',
225 'values' => array(
'N',
'Y'),
228 'INDEX_SECTION' => array(
229 'data_type' =>
'boolean',
230 'values' => array(
'N',
'Y'),
234 'data_type' =>
'boolean',
235 'values' => array(
'N',
'Y'),
239 'data_type' =>
'boolean',
240 'values' => array(
'N',
'Y'),
243 'SECTION_CHOOSER' => array(
244 'data_type' =>
'enum',
246 self::SECTION_CHOOSER_SELECT,
247 self::SECTION_CHOOSER_DROPDOWNS,
248 self::SECTION_CHOOSER_PATH
250 'default_value' => self::SECTION_CHOOSER_SELECT,
253 'LIST_MODE' => array(
254 'data_type' =>
'enum',
255 'values' => array(self::LIST_MODE_COMBINED, self::LIST_MODE_SEPARATE),
256 'default_value' => self::LIST_MODE_COMBINED,
259 'RIGHTS_MODE' => array(
260 'data_type' =>
'enum',
261 'values' => array(self::RIGHTS_SIMPLE, self::RIGHTS_EXTENDED),
262 'default_value' => self::RIGHTS_SIMPLE,
265 'SECTION_PROPERTY' => array(
266 'data_type' =>
'boolean',
267 'values' => array(
'N',
'Y'),
270 'PROPERTY_INDEX' => array(
271 'data_type' =>
'enum',
272 'values' => array(self::PROPERTY_INDEX_DISABLE, self::PROPERTY_INDEX_ENABLE, self::PROPERTY_INDEX_INVALID),
273 'default' => self::PROPERTY_INDEX_DISABLE,
277 'data_type' =>
'enum',
278 'values' => array(self::PROPERTY_STORAGE_COMMON, self::PROPERTY_STORAGE_SEPARATE),
279 'default_value' => self::PROPERTY_STORAGE_COMMON,
282 'LAST_CONV_ELEMENT' => array(
283 'data_type' =>
'integer',
286 'SOCNET_GROUP_ID' => array(
287 'data_type' =>
'integer',
290 'EDIT_FILE_BEFORE' => array(
291 'data_type' =>
'string',
293 'validation' => array(__CLASS__,
'validateEditFileBefore'),
295 'EDIT_FILE_AFTER' => array(
296 'data_type' =>
'string',
298 'validation' => array(__CLASS__,
'validateEditFileAfter'),
301 'data_type' =>
'Bitrix\Iblock\Type',
302 'reference' => array(
'=this.IBLOCK_TYPE_ID' =>
'ref.ID'),
305 new OneToMany(
'PROPERTIES', PropertyTable::class,
'IBLOCK')
317 public static function compileEntity($iblockApiCode)
320 if ($iblockApiCode instanceof
Iblock)
322 $iblock = $iblockApiCode;
323 $iblock->fillApiCode();
328 'select' => [
'ID',
'API_CODE'],
329 'filter' => Query::filter()->where(
'API_CODE', $iblockApiCode)
333 if (!$iblock || empty($iblock->getApiCode()))
339 $iblockNamespace = static::DATA_CLASS_NAMESPACE;
340 $iblockDataClassName = $iblock->getEntityDataClassName();
342 if ($iblockDataClassName ==
'')
348 $iblockDataClass = $iblock->getEntityDataClass();
350 if (class_exists($iblockDataClass,
false))
352 return $iblockDataClass::getEntity();
356 $iblock->fill([
'VERSION',
'PROPERTIES']);
359 $parentDataClass = $iblock->getVersion() == 1
360 ? ElementV1Table::class
361 : ElementV2Table::class;
364 $elementEntity = \Bitrix\Main\ORM\Entity::compileEntity(
365 $iblockDataClassName,
368 'namespace' => $iblockNamespace,
369 'parent' => $parentDataClass,
374 $elementEntity->setIblock($iblock);
377 SectionElementTable::getEntity()->addField(
378 (
new Reference(
'REGULAR_ELEMENT_'.$iblock->getId(), $elementEntity,
379 Join::on(
'this.IBLOCK_ELEMENT_ID',
'ref.ID')->whereNull(
'this.ADDITIONAL_PROPERTY_ID')))
382 $elementEntity->addField((
new ManyToMany(
'SECTIONS', SectionTable::class))
383 ->configureMediatorEntity(SectionElementTable::class)
384 ->configureLocalReference(
'REGULAR_ELEMENT_'.$iblock->getId())
385 ->configureRemoteReference(
'IBLOCK_SECTION')
389 $userTypeList = CIBlockProperty::GetUserType();
392 foreach ($iblock->getProperties() as $property)
394 if (empty($property->getCode()))
400 $propertyValueEntity = $property->getValueEntity($elementEntity);
403 if (!empty($property->getUserType()) && !empty($userTypeList[$property->getUserType()][
'GetORMFields']))
405 call_user_func($userTypeList[$property->getUserType()][
'GetORMFields'], $propertyValueEntity, $property);
409 $niceColumnName = $property->getCode();
411 if ($property->getMultiple())
414 $elementRefName =
'SRC_ELEMENT';
417 $propertyValueEntity->addField(
421 Join::on(
'this.IBLOCK_ELEMENT_ID',
'ref.ID')
422 ->where(
'this.IBLOCK_PROPERTY_ID', $property->getId())
424 ->configureJoinType(Join::TYPE_INNER)
429 $elementEntity->addField(
430 (
new PropertyOneToMany($niceColumnName, $propertyValueEntity, $elementRefName))
431 ->configureJoinType(Join::TYPE_LEFT)
433 ->configureCascadeDeletePolicy(
441 $joinType = Join::TYPE_INNER;
442 $joinFilter = Join::on(
'this.ID',
'ref.IBLOCK_ELEMENT_ID');
444 if ($iblock->getVersion() == 1)
447 $joinType = Join::TYPE_LEFT;
448 $joinFilter->where(
'ref.IBLOCK_PROPERTY_ID', $property->getId());
452 $elementEntity->addField(
453 (
new PropertyReference($niceColumnName, $propertyValueEntity, $joinFilter))
454 ->configureJoinType($joinType)
456 ->configureCascadeDeletePolicy(
463 return $elementEntity;
473 foreach (static::getList([
'select' => [
'ID',
'API_CODE']])->fetchCollection() as $iblock)
475 static::compileEntity($iblock);
487 new Entity\Validator\Length(
null, 50),
499 new Entity\Validator\Length(
null, 2),
511 new Entity\Validator\Length(
null, 50),
523 new Entity\Validator\Length(
null, 255),
535 new Entity\Validator\Length(
null, 255),
547 new Entity\Validator\Length(
null, 255),
559 new Entity\Validator\Length(
null, 255),
571 new Entity\Validator\Length(
null, 255),
583 new Entity\Validator\Length(
null, 255),
595 new Entity\Validator\Length(
null, 40),
607 new Entity\Validator\Length(
null, 255),
619 new Entity\Validator\Length(
null, 255),
632 \CIBlock::CleanCache($primary[
'ID']);
644 \CIBlock::CleanCache($primary[
'ID']);
656 \CIBlock::CleanCache($primary[
'ID']);
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)
static getList(array $parameters=array())