35 return ElementEntity::class;
45 return $query->where(
"IBLOCK_ID", static::getEntity()->getIblock()->getId());
67 $class = static::getEntityClass()::normalizeEntityClass(get_called_class());
69 if (!isset(static::$entity[$class]))
72 $parentClass = get_parent_class(get_called_class());
76 [ElementV1Table::class, ElementV2Table::class]
79 static::$entity[$class] = clone $parentClass::getEntity();
80 static::$entity[$class]->reinitialize($class);
84 static::$entity[$class] = parent::getEntity();
88 return static::$entity[$class];
103 foreach (
$rows as $row)
105 if (!empty($row[
'__object']))
107 $result = $row[
'__object']->save();
120 $object =
$event->getParameter(
'object');
121 $fields = static::getEntity()->getFields();
128 $hasEmptyRequiredValue =
false;
132 $property = $field->getIblockElementProperty();
134 if ($property->getIsRequired())
137 $valueContainer = $object->get($field->getName());
139 if (empty($valueContainer))
141 $hasEmptyRequiredValue =
true;
145 if ($valueContainer instanceof ValueStorage)
147 $userType = CIBlockProperty::GetUserType($property->getUserType());
149 if(array_key_exists(
"GetLength", $userType))
151 $length = call_user_func_array(
152 $userType[
"GetLength"],
154 $property->collectValues(),
155 [
"VALUE" => $valueContainer->getValue()]
161 $length = mb_strlen($valueContainer->getValue());
164 $hasEmptyRequiredValue = ($length <= 0);
168 if ($hasEmptyRequiredValue)
170 $result->addError(
new FieldError(
173 "MAIN_ENTITY_FIELD_REQUIRED",
174 [
"#FIELD#" => $property->getName()]
188 $elementId = (int) end(
$event->getParameters()[
'primary']);
189 $iblockId = static::getEntity()->getIblock()->getId();
200 $elementId = (int) end(
$event->getParameters()[
'primary']);
201 $iblockId = static::getEntity()->getIblock()->getId();
212 parent::onAfterDelete(
$event);
214 $elementId = (int) end(
$event->getParameters()[
'primary']);
215 $iblockId = static::getEntity()->getIblock()->getId();
216 $connection = static::getEntity()->getConnection();
219 $tables = [static::getEntity()->getSingleValueTableName(), static::getEntity()->getMultiValueTableName()];
221 foreach (array_unique($tables) as
$table)
223 $connection->query(
"DELETE FROM {$table} WHERE IBLOCK_ELEMENT_ID = {$elementId}");
static onBeforeAdd(Event $event)