59 'abstract',
'and',
'array',
'as',
'break',
'callable',
'case',
'catch',
'class',
'clone',
'const',
'continue',
60 'declare',
'default',
'die',
'do',
'echo',
'else',
'elseif',
'empty',
'enddeclare',
'endfor',
'endforeach',
61 'endif',
'endswitch',
'endwhile',
'eval',
'exit',
'extends',
'final',
'finally',
'for',
'foreach',
'function',
62 'global',
'goto',
'if',
'implements',
'include',
'include_once',
'instanceof',
'insteadof',
'interface',
'isset',
63 'list',
'namespace',
'new',
'or',
'print',
'private',
'protected',
'public',
'require',
'require_once',
'return',
64 'static',
'switch',
'throw',
'trait',
'try',
'unset',
'use',
'var',
'while',
'xor',
'yield',
68 'int',
'float',
'bool',
'string',
'true',
'false',
'null',
'void',
'iterable',
'object',
'resource',
'mixed',
'numeric',
80 $class = static::getEntityClass()::normalizeEntityClass(get_called_class());
82 if (!isset(static::$entity[$class]))
84 static::$entity[$class] = static::getEntityClass()::getInstance($class);
87 return static::$entity[$class];
92 $class = static::getEntityClass()::normalizeEntityClass($class);
94 if (isset(static::$entity[$class]))
96 unset(static::$entity[$class]);
135 if (!isset(static::$objectClass[get_called_class()]))
137 static::$objectClass[get_called_class()] = static::getObjectClassByDataClass(get_called_class());
140 return static::$objectClass[get_called_class()];
150 $class = static::getObjectClass();
151 return substr($class, strrpos($class,
'\\') + 1);
156 $objectClass = static::getEntityClass()::normalizeName($dataClass);
162 $className = static::getEntityClass()::getDefaultObjectClassName($className);
164 return $namespace.$className;
174 if (!isset(static::$collectionClass[get_called_class()]))
176 static::$collectionClass[get_called_class()] = static::getCollectionClassByDataClass(get_called_class());
179 return static::$collectionClass[get_called_class()];
189 $class = static::getCollectionClass();
190 return substr($class, strrpos($class,
'\\') + 1);
195 $objectClass = static::getEntityClass()::normalizeName($dataClass);
201 $className = static::getEntityClass()::getDefaultCollectionClassName($className);
203 return $namespace.$className;
211 return EntityObject::class;
219 return Collection::class;
235 return Entity::class;
247 return static::getEntity()->createObject($setDefaultValues);
257 return static::getEntity()->createCollection();
271 return static::getEntity()->wakeUpObject($row);
285 return static::getEntity()->wakeUpCollection($rows);
343 public static function getByPrimary($primary, array $parameters = array())
345 static::normalizePrimary($primary);
346 static::validatePrimary($primary);
348 $primaryFilter = array();
350 foreach ($primary as $k => $v)
352 $primaryFilter[
'='.$k] = $v;
355 if (isset($parameters[
'filter']))
357 $parameters[
'filter'] = array($primaryFilter, $parameters[
'filter']);
361 $parameters[
'filter'] = $primaryFilter;
364 return static::getList($parameters);
379 return static::getByPrimary($id);
394 $result = static::getByPrimary($id);
395 $row = $result->fetch();
397 return (is_array($row)? $row :
null);
410 public static function getRow(array $parameters)
412 $parameters[
'limit'] = 1;
413 $result = static::getList($parameters);
414 $row = $result->fetch();
416 return (is_array($row)? $row :
null);
441 public static function getList(array $parameters = array())
443 $query = static::query();
445 if(!isset($parameters[
'select']))
447 $query->setSelect(array(
'*'));
450 foreach($parameters as $param => $value)
455 $query->setSelect($value);
458 $value instanceof Filter ? $query->where($value) : $query->setFilter($value);
461 $query->setGroup($value);
464 $query->setOrder($value);
467 $query->setLimit($value);
470 $query->setOffset($value);
473 $query->countTotal($value);
476 foreach ($value as $name => $fieldInfo)
478 $query->registerRuntimeField($name, $fieldInfo);
481 case 'data_doubling':
484 $query->enableDataDoubling();
488 $query->disableDataDoubling();
491 case 'private_fields':
494 $query->enablePrivateFields();
498 $query->disablePrivateFields();
502 $query->setCacheTtl($value[
"ttl"]);
503 if(isset($value[
"cache_joins"]))
505 $query->cacheJoins($value[
"cache_joins"]);
513 return $query->exec();
526 public static function getCount($filter = array(), array $cache = array())
528 $query = static::query();
533 if ($filter instanceof Filter)
535 $query->where($filter);
539 $query->setFilter($filter);
542 if(isset($cache[
"ttl"]))
544 $query->setCacheTtl($cache[
"ttl"]);
547 $result = $query->exec()->fetch();
549 return (
int)$result[
'CNT'];
561 $queryClass = static::getQueryClass();
562 return new $queryClass(static::getEntity());
577 foreach ($data as $fieldName => $value)
579 $newData[
$entity->getField($fieldName)->getColumnName()] = $value;
592 protected static function normalizePrimary(&$primary, $data = array())
595 $entity_primary =
$entity->getPrimaryArray();
597 if ($primary ===
null)
602 foreach ($entity_primary as $key)
605 $field =
$entity->getField($key);
606 if ($field->isAutocomplete())
611 if (!isset($data[$key]))
614 'Primary `%s` was not found when trying to query %s row.', $key,
$entity->getName()
618 $primary[$key] = $data[$key];
621 elseif (is_scalar($primary))
623 if (count($entity_primary) > 1)
625 throw new Main\ArgumentException(sprintf(
626 'Require multi primary {`%s`}, but one scalar value "%s" found when trying to query %s row.',
627 join(
'`, `', $entity_primary), $primary,
$entity->getName()
631 $primary = array($entity_primary[0] => $primary);
644 if (is_array($primary))
649 'Empty primary found when trying to query %s row.',
$entity->getName()
653 $entity_primary =
$entity->getPrimaryArray();
655 foreach (array_keys($primary) as $key)
657 if (!in_array($key, $entity_primary,
true))
660 'Unknown primary `%s` found when trying to query %s row.',
669 'Unknown type of primary "%s" found when trying to query %s row.', gettype($primary),
$entity->getName()
674 foreach ($primary as $key => $value)
676 if (!is_scalar($value) && !($value instanceof Main\
Type\
Date))
679 'Unknown value type "%s" for primary "%s" found when trying to query %s row.',
680 gettype($value), $key,
$entity->getName()
700 foreach (
$entity->getFields() as $field)
704 $fieldName = $field->getName();
706 (empty($primary) && (!isset($data[$fieldName]) || $field->isValueEmpty($data[$fieldName])))
707 || (!empty($primary) && array_key_exists($fieldName, $data) && $field->isValueEmpty($data[$fieldName]))
712 Loc::getMessage(
"MAIN_ENTITY_FIELD_REQUIRED", array(
"#FIELD#"=>$field->getTitle())),
713 FieldError::EMPTY_REQUIRED
720 foreach ($data as $k => $v)
724 $field =
$entity->getField($k);
730 'Field `%s` not found in entity when trying to query %s row.',
735 $field->validateValue($v, $primary, $data, $result);
748 protected static function convertArrayToObject(&$fields, $setDefaultValues =
false, $primary =
null)
753 if (isset($fields[
"fields"]) && is_array($fields[
"fields"]))
756 $fields = $data[
"fields"];
760 if (isset($fields[
'__object']))
762 $object = $fields[
'__object'];
763 unset($fields[
'__object']);
770 if ($primary ===
null)
772 $object =
$entity->createObject($setDefaultValues);
774 foreach ($fields as $fieldName => $value)
777 if (
$entity->hasField($fieldName))
779 $object->sysSetValue($fieldName, $value);
785 $object =
$entity->wakeUpObject($primary);
787 foreach ($fields as $fieldName => $value)
790 if (
$entity->hasField($fieldName))
792 if (
$entity->getField($fieldName) instanceof ScalarField &&
$entity->getField($fieldName)->isPrimary())
795 if (array_key_exists($fieldName, $primary) && $primary[$fieldName] == $value)
797 unset($fields[$fieldName]);
802 trigger_error(sprintf(
803 'Primary of %s %s can not be changed. You can delete this row and add a new one',
804 static::getObjectClass(), Main\Web\
Json::encode($object->primary)
810 $object->sysSetValue($fieldName, $value);
817 if (isset($data[
'auth_context']))
819 $object->authContext = $data[
'auth_context'];
832 global $USER_FIELD_MANAGER, $APPLICATION;
834 $userId = ($object->authContext && $object->authContext->getUserId())
835 ? $object->authContext->getUserId()
838 $ufPrimary = ($object->sysGetState() === Main\ORM\Objectify\State::RAW)
840 : end($object->primary);
842 if (!$USER_FIELD_MANAGER->CheckFields($object->entity->getUfId(), $ufPrimary, $ufdata, $userId))
844 if (is_object($APPLICATION) && $APPLICATION->getException())
846 $e = $APPLICATION->getException();
847 $result->addError(
new EntityError($e->getString()));
848 $APPLICATION->resetException();
852 $result->addError(
new EntityError(
"Unknown error while checking userfields"));
874 public static function add(array $data)
876 global $USER_FIELD_MANAGER;
882 $object = static::convertArrayToObject($fields,
true);
889 static::callOnBeforeAddEvent($object, $fields, $result);
892 $fields = $object->collectValues(Values::CURRENT, FieldTypeMask::SCALAR);
895 $ufdata = $object->collectValues(Values::CURRENT, FieldTypeMask::USERTYPE);
898 static::checkFields($result,
null, $fields);
903 static::checkUfFields($object, $ufdata, $result);
907 if (empty($fields) && empty($ufdata))
909 $result->addError(
new EntityError(
"There is no data to add."));
913 if (!$result->isSuccess(
true))
922 $fieldsToDb = $fields;
924 foreach ($fieldsToDb as $fieldName => $value)
926 $field =
$entity->getField($fieldName);
927 if ($field->isPrimary() && $field->isAutocomplete() && is_null($value))
929 unset($fieldsToDb[$fieldName]);
932 $fieldsToDb[$fieldName] = $field->modifyValueBeforeSave($value, $fields);
936 $connection =
$entity->getConnection();
938 $tableName =
$entity->getDBTableName();
939 $identity =
$entity->getAutoIncrement();
941 $dataReplacedColumn = static::replaceFieldName($fieldsToDb);
942 $id = $connection->add($tableName, $dataReplacedColumn, $identity);
946 $isGuessedPrimary =
false;
950 if(
$entity->getAutoIncrement() <>
'')
952 $primary = array(
$entity->getAutoIncrement() => $id);
953 static::normalizePrimary($primary);
958 $primary = array(
'ID' => $id);
959 $isGuessedPrimary =
true;
964 static::normalizePrimary($primary, $fields);
968 $result->setPrimary($primary);
969 $result->setData($fields + $ufdata);
970 $result->setObject($object);
972 if (!$isGuessedPrimary)
974 foreach ($primary as $primaryName => $primaryValue)
976 $object->sysSetActual($primaryName, $primaryValue);
985 if ($object->authContext)
987 $ufUserId = $object->authContext->getUserId();
990 $USER_FIELD_MANAGER->update(
$entity->getUfId(), end($primary), $ufdata, $ufUserId);
993 static::cleanCache();
995 static::callOnAfterAddEvent($object, $fields + $ufdata, $id);
997 catch (\Exception $e)
1000 $result->isSuccess();
1016 public static function addMulti($rows, $ignoreEvents =
false)
1018 global $USER_FIELD_MANAGER;
1020 $rows = array_values($rows);
1021 $forceSeparateQueries =
false;
1023 if (!$ignoreEvents && count($rows) > 1 && strlen(static::getEntity()->getAutoIncrement()))
1025 $forceSeparateQueries =
true;
1029 'Multi-insert doesn\'t work with events as far as we can not get last inserted IDs that we need for the events. '.
1030 'Insert query was forced to multiple separate queries.',
1038 foreach ($rows as $k => &$row)
1040 $objects[$k] = static::convertArrayToObject($row,
true);
1043 $entity = static::getEntity();
1051 foreach ($objects as $k => $object)
1053 static::callOnBeforeAddEvent($object, $rows[$k], $result);
1061 foreach ($objects as $k => $object)
1064 $allFields[$k] = $object->collectValues(Values::CURRENT, FieldTypeMask::SCALAR);
1067 $allUfData[$k] = $object->collectValues(Values::CURRENT, FieldTypeMask::USERTYPE);
1071 foreach ($objects as $k => $object)
1073 $fields = $allFields[$k];
1074 $ufdata = $allUfData[$k];
1077 static::checkFields($result,
null, $fields);
1080 if (!empty($ufdata))
1082 static::checkUfFields($object, $ufdata, $result);
1086 if (empty($fields) && empty($ufdata))
1088 $result->addError(
new EntityError(
"There is no data to add."));
1093 if (!$result->isSuccess(
true))
1101 foreach ($objects as $k => $object)
1103 $fields = $allFields[$k];
1104 $ufdata = $allUfData[$k];
1113 foreach ($allFields as $k => $fields)
1116 $fieldsToDb = $fields;
1118 foreach ($fieldsToDb as $fieldName => $value)
1120 $field =
$entity->getField($fieldName);
1121 $fieldsToDb[$fieldName] = $field->modifyValueBeforeSave($value, $fields);
1124 $dataReplacedColumn = static::replaceFieldName($fieldsToDb);
1126 $allSqlData[$k] = $dataReplacedColumn;
1130 $connection =
$entity->getConnection();
1132 $tableName =
$entity->getDBTableName();
1133 $identity =
$entity->getAutoIncrement();
1137 if ($forceSeparateQueries)
1139 foreach ($allSqlData as $k => $sqlData)
1142 $ids[$k] = $connection->add($tableName, $sqlData, $identity);
1147 $id = $connection->addMulti($tableName, $allSqlData, $identity);
1150 if (count($allSqlData) > 1)
1157 $object = $objects[0];
1158 $fields = $allFields[0];
1165 if(
$entity->getAutoIncrement() <>
'')
1167 $primary = array(
$entity->getAutoIncrement() => $id);
1168 static::normalizePrimary($primary);
1173 $primary = array(
'ID' => $id);
1178 static::normalizePrimary($primary, $fields);
1182 $result->setPrimary($primary);
1183 $result->setData($fields);
1184 $result->setObject($object);
1188 foreach ($allUfData as $k => $ufdata)
1190 if (!empty($ufdata))
1194 if ($objects[$k]->authContext)
1196 $ufUserId = $objects[$k]->authContext->getUserId();
1199 $USER_FIELD_MANAGER->update(
$entity->getUfId(), end($primary), $ufdata, $ufUserId);
1203 static::cleanCache();
1208 foreach ($objects as $k => $object)
1210 $fields = $allFields[$k] + $allUfData[$k];
1211 $id = $forceSeparateQueries ? $ids[$k] :
null;
1213 static::callOnAfterAddEvent($object, $fields, $id);
1217 catch (\Exception $e)
1220 $result->isSuccess();
1246 public static function update($primary, array $data)
1248 global $USER_FIELD_MANAGER;
1251 static::normalizePrimary(
1252 $primary, isset($data[
"fields"]) && is_array($data[
"fields"]) ? $data[
"fields"] : $data
1254 static::validatePrimary($primary);
1260 $object = static::convertArrayToObject($fields,
false, $primary);
1262 $entity = static::getEntity();
1267 static::callOnBeforeUpdateEvent($object, $fields, $result);
1270 $fields = $object->collectValues(Values::CURRENT, FieldTypeMask::SCALAR);
1273 $ufdata = $object->collectValues(Values::CURRENT, FieldTypeMask::USERTYPE);
1276 static::checkFields($result, $primary, $fields);
1279 if (!empty($ufdata))
1281 static::checkUfFields($object, $ufdata, $result);
1285 if (empty($fields) && empty($ufdata))
1291 if (!$result->isSuccess(
true))
1296 static::callOnUpdateEvent($object, $fields, $ufdata);
1299 $fieldsToDb = $fields;
1301 foreach ($fieldsToDb as $fieldName => $value)
1303 $field =
$entity->getField($fieldName);
1304 $fieldsToDb[$fieldName] = $field->modifyValueBeforeSave($value, $fields);
1308 if (!empty($fieldsToDb))
1310 $connection =
$entity->getConnection();
1311 $helper = $connection->getSqlHelper();
1313 $tableName =
$entity->getDBTableName();
1315 $dataReplacedColumn = static::replaceFieldName($fieldsToDb);
1316 $update = $helper->prepareUpdate($tableName, $dataReplacedColumn);
1318 $replacedPrimary = static::replaceFieldName($primary);
1320 foreach ($replacedPrimary as $k => $v)
1322 $id[] = $helper->prepareAssignment($tableName, $k, $v);
1324 $where = implode(
' AND ', $id);
1326 $sql =
"UPDATE ".$helper->quote($tableName).
" SET ".$update[0].
" WHERE ".$where;
1327 $connection->queryExecute($sql, $update[1]);
1329 $result->setAffectedRowsCount($connection);
1332 $result->setData($fields + $ufdata);
1333 $result->setPrimary($primary);
1334 $result->setObject($object);
1337 if (!empty($ufdata))
1341 if ($object->authContext)
1343 $ufUserId = $object->authContext->getUserId();
1346 $USER_FIELD_MANAGER->update(
$entity->getUfId(), end($primary), $ufdata, $ufUserId);
1349 static::cleanCache();
1352 static::callOnAfterUpdateEvent($object, $fields + $ufdata);
1354 catch (\Exception $e)
1357 $result->isSuccess();
1374 public static function updateMulti($primaries, $data, $ignoreEvents =
false)
1376 $entity = static::getEntity();
1377 $primaries = array_values($primaries);
1382 foreach ($primaries as &$primary)
1384 static::normalizePrimary($primary, $data);
1385 static::validatePrimary($primary);
1388 $object =
$entity->wakeUpObject($primary);
1390 foreach ($data as $k => $v)
1392 $object->set($k, $v);
1395 $objects[] = $object;
1405 foreach ($objects as $object)
1407 static::callOnBeforeUpdateEvent($object, $data, $result);
1415 foreach ($objects as $k => $object)
1418 $allFields[$k] = $object->collectValues(Values::CURRENT, FieldTypeMask::SCALAR);
1421 $allUfData[$k] = $object->collectValues(Values::CURRENT, FieldTypeMask::USERTYPE);
1425 foreach ($objects as $k => $object)
1427 $fields = $allFields[$k];
1428 $ufdata = $allUfData[$k];
1431 static::checkFields($result, $object->primary, $fields);
1434 if (!empty($ufdata))
1436 static::checkUfFields($object, $ufdata, $result);
1440 if (empty($fields) && empty($ufdata))
1442 $result->addError(
new EntityError(
"There is no data to add."));
1447 if (!$result->isSuccess(
true))
1455 foreach ($objects as $k => $object)
1457 $fields = $allFields[$k];
1458 $ufdata = $allUfData[$k];
1460 static::callOnUpdateEvent($object, $fields, $ufdata);
1467 foreach ($allFields as $k => $fields)
1470 $fieldsToDb = $fields;
1472 foreach ($fieldsToDb as $fieldName => $value)
1474 $field =
$entity->getField($fieldName);
1475 $fieldsToDb[$fieldName] = $field->modifyValueBeforeSave($value, $fields);
1478 $dataReplacedColumn = static::replaceFieldName($fieldsToDb);
1480 $allSqlData[$k] = $dataReplacedColumn;
1486 $dataSample = $allSqlData[0];
1489 if (!empty($allSqlData[0]))
1492 foreach ($allSqlData as $data)
1496 if ($data !== $dataSample)
1504 $connection =
$entity->getConnection();
1505 $helper = $connection->getSqlHelper();
1506 $tableName =
$entity->getDBTableName();
1512 $update = $helper->prepareUpdate($tableName, $dataSample);
1514 $isSinglePrimary = (count(
$entity->getPrimaryArray()) == 1);
1516 foreach ($allSqlData as $k => $data)
1518 $replacedPrimary = static::replaceFieldName($objects[$k]->primary);
1520 if ($isSinglePrimary)
1523 $primaryName = key($replacedPrimary);
1524 $primaryValue = current($replacedPrimary);
1525 $tableField =
$entity->getConnection()->getTableField($tableName, $primaryName);
1527 $where[] = $helper->convertToDb($primaryValue, $tableField);
1533 foreach ($replacedPrimary as $primaryName => $primaryValue)
1535 $id[] = $helper->prepareAssignment($tableName, $primaryName, $primaryValue);
1537 $where[] = implode(
' AND ', $id);
1541 if ($isSinglePrimary)
1543 $where = $helper->quote(
$entity->getPrimary()).
' IN ('.join(
', ', $where).
')';
1547 $where =
'('.join(
') OR (', $where).
')';
1550 $sql =
"UPDATE ".$helper->quote($tableName).
" SET ".$update[0].
" WHERE ".$where;
1551 $connection->queryExecute($sql, $update[1]);
1553 $result->setAffectedRowsCount($connection);
1558 foreach ($allSqlData as $k => $dataReplacedColumn)
1560 $update = $helper->prepareUpdate($tableName, $dataReplacedColumn);
1562 $replacedPrimary = static::replaceFieldName($objects[$k]->primary);
1566 foreach ($replacedPrimary as $primaryName => $primaryValue)
1568 $id[] = $helper->prepareAssignment($tableName, $primaryName, $primaryValue);
1570 $where = implode(
' AND ', $id);
1572 $sql =
"UPDATE ".$helper->quote($tableName).
" SET ".$update[0].
" WHERE ".$where;
1573 $connection->queryExecute($sql, $update[1]);
1575 $result->setAffectedRowsCount($connection);
1581 $result->setData($dataSample);
1583 if (count($allSqlData) == 1)
1585 $result->setPrimary($objects[0]->primary);
1586 $result->setObject($objects[0]);
1590 foreach ($allUfData as $ufdata)
1592 if (!empty($ufdata))
1594 global $USER_FIELD_MANAGER;
1595 $USER_FIELD_MANAGER->update(
$entity->getUfId(), end($primary), $ufdata);
1599 static::cleanCache();
1604 foreach ($objects as $k => $object)
1606 $fields = $allFields[$k] + $allUfData[$k];
1608 static::callOnAfterUpdateEvent($object, $fields);
1612 catch (\Exception $e)
1615 $result->isSuccess();
1632 public static function delete($primary)
1634 global $USER_FIELD_MANAGER;
1637 static::normalizePrimary($primary);
1638 static::validatePrimary($primary);
1640 $entity = static::getEntity();
1643 $entityClass = static::getEntity()->getDataClass();
1644 $primaryAsString = EntityObject::sysSerializePrimary($primary, static::getEntity());
1646 $object = !empty(static::$currentDeletingObjects[$entityClass][$primaryAsString])
1647 ? static::$currentDeletingObjects[$entityClass][$primaryAsString]
1648 : static::wakeUpObject($primary);
1653 static::callOnBeforeDeleteEvent($object,
$entity, $result);
1656 if (!$result->isSuccess(
true))
1662 static::callOnDeleteEvent($object,
$entity);
1665 $connection =
$entity->getConnection();
1666 $helper = $connection->getSqlHelper();
1668 $tableName =
$entity->getDBTableName();
1670 $replacedPrimary = static::replaceFieldName($primary);
1672 foreach ($replacedPrimary as $k => $v)
1674 $id[] = $helper->prepareAssignment($tableName, $k, $v);
1676 $where = implode(
' AND ', $id);
1678 $sql =
"DELETE FROM ".$helper->quote($tableName).
" WHERE ".$where;
1679 $connection->queryExecute($sql);
1684 $USER_FIELD_MANAGER->delete(
$entity->getUfId(), end($primary));
1687 static::cleanCache();
1690 static::callOnAfterDeleteEvent($object,
$entity);
1692 catch (\Exception $e)
1695 $result->isSuccess();
1702 if (!empty(static::$currentDeletingObjects[$entityClass][$primaryAsString]))
1704 unset(static::$currentDeletingObjects[$entityClass][$primaryAsString]);
1719 $event =
new Event($object->entity, self::EVENT_ON_BEFORE_ADD, [
1720 'fields' => $fields,
1725 $event->getErrors($result);
1726 $event->mergeObjectFields($object);
1729 $event =
new Event($object->entity, self::EVENT_ON_BEFORE_ADD, [
1730 'fields' => $fields,
1735 $event->getErrors($result);
1736 $event->mergeObjectFields($object);
1746 $event =
new Event($object->entity, self::EVENT_ON_ADD, [
1747 'fields' => $fields + $ufdata,
1748 'object' => clone $object
1753 $event =
new Event($object->entity, self::EVENT_ON_ADD, [
1754 'fields' => $fields + $ufdata,
1755 'object' => clone $object
1768 $event =
new Event($object->entity, self::EVENT_ON_AFTER_ADD, [
1770 'fields' => $fields,
1771 'object' => clone $object
1776 $event =
new Event($object->entity, self::EVENT_ON_AFTER_ADD, [
1778 'primary' => $object->primary,
1779 'fields' => $fields,
1780 'object' => clone $object
1792 $event =
new Event($object->entity, self::EVENT_ON_BEFORE_UPDATE, [
1793 'id' => $object->primary,
1794 'fields' => $fields,
1799 $event->getErrors($result);
1800 $event->mergeObjectFields($object);
1803 $event =
new Event($object->entity, self::EVENT_ON_BEFORE_UPDATE, [
1804 'id' => $object->primary,
1805 'primary' => $object->primary,
1806 'fields' => $fields,
1811 $event->getErrors($result);
1812 $event->mergeObjectFields($object);
1822 $event =
new Event($object->entity, self::EVENT_ON_UPDATE, [
1823 'id' => $object->primary,
1824 'fields' => $fields + $ufdata,
1825 'object' => clone $object
1830 $event =
new Event($object->entity, self::EVENT_ON_UPDATE, [
1831 'id' => $object->primary,
1832 'primary' => $object->primary,
1833 'fields' => $fields + $ufdata,
1834 'object' => clone $object
1845 $event =
new Event($object->entity, self::EVENT_ON_AFTER_UPDATE, [
1846 'id' => $object->primary,
1847 'fields' => $fields,
1848 'object' => clone $object
1853 $event =
new Event($object->entity, self::EVENT_ON_AFTER_UPDATE, [
1854 'id' => $object->primary,
1855 'primary' => $object->primary,
1856 'fields' => $fields,
1857 'object' => clone $object
1869 $event =
new Event(
$entity, self::EVENT_ON_BEFORE_DELETE, array(
"id" => $object->primary));
1871 $event->getErrors($result);
1874 $event =
new Event(
$entity, self::EVENT_ON_BEFORE_DELETE, array(
"id" => $object->primary,
"primary" => $object->primary,
"object" => clone $object),
true);
1876 $event->getErrors($result);
1885 $event =
new Event(
$entity, self::EVENT_ON_DELETE, array(
"id" => $object->primary));
1889 $event =
new Event(
$entity, self::EVENT_ON_DELETE, array(
"id" => $object->primary,
"primary" => $object->primary,
"object" => clone $object),
true);
1899 $event =
new Event(
$entity, self::EVENT_ON_AFTER_DELETE, array(
"id" => $object->primary));
1903 $event =
new Event(
$entity, self::EVENT_ON_AFTER_DELETE, array(
"id" => $object->primary,
"primary" => $object->primary,
"object" => clone $object),
true);
1918 $table = static::getTableName();
1921 $optionString = Main\Config\Option::get(
"main",
"~crypto_".$table);
1922 if($optionString <>
'')
1924 $options = unserialize($optionString, [
'allowed_classes' =>
false]);
1926 $options[strtoupper($field)] = $mode;
1927 Main\Config\Option::set(
"main",
"~crypto_".$table, serialize($options));
1942 $table = static::getTableName();
1944 $optionString = Main\Config\Option::get(
"main",
"~crypto_".$table);
1945 if($optionString <>
'')
1947 $field = strtoupper($field);
1948 $options = unserialize($optionString, [
'allowed_classes' =>
false]);
1949 if(isset($options[$field]) && $options[$field] ===
true)
1962 $entityClass = static::getEntity()->getDataClass();
1963 self::$currentDeletingObjects[$entityClass][$object->primaryAsString] = $object;
1968 $entity = static::getEntity();