Documentation

PrototypeItemDataManager

Description and methods

Abstract class for abstract item data manager prototypes. Contains API for user fields modifications before saving them into database.


Inheritance chain

Descendant for class Bitrix\Main\ORM\Data\DataManager.

Methods

Method Description Available from version
public static function getType(): ?array Returns array-type description for final compiled data manager class.
public static function getMap(): array Items only have ID by default. however, descendants can add their own system fields, as done in the RPA module.
public static function checkFields(ORM\Data\Result $result, $primary, array $data) Re-defined parent class to avoid querying to user field API for search results.
public static function getItemUserFieldEntityId(): ?string Returns string ID for user fields entity for specific data manager.
public static function isOwnField(string $fieldName): bool Returns true, when entity has system field with code $fieldName.
public static function getOwnFieldNames(): array Returns array with field system names.

Data conversion

Event handler methods converting data for properly saving in database

Here field values are processed for storage in the database:

  • public static function onBeforeAdd(Event $event): ORM\EventResult
  • public static function onBeforeUpdate(Event $event): ORM\EventResult

Here multiple field values are saved into separate tables:

  • public static function onAfterAdd(Event $event): ORM\EventResult
  • public static function onAfterUpdate(Event $event): ORM\EventResult

After item is deleted, all data from associated tables is delated as well - from multiple value tables, from b_file

  • public static function onAfterDelete(Event $event): ORM\EventResult

Processing of events issued from old user fields API

User fields API have methods allowing directly to change values. These methods have directly queried to own tables and wrote new values into them.

Now this option is unavailable, because these tables do not exist. To avoid error while working via old API, new events were added to be captured by UserFieldHelper. These events request methods of this class:

  • public static function getUserFieldValues(int $id, array $userFields): ?array - returns array of user field values with codes $userFields for item with ID $id. Returns null, when such item does not exist;
  • public static function updateUserFieldValues(int $id, array $fields): Main\Result - updates user field values for item with ID $id. The array $fields contains field codes and values;
  • public static function deleteUserFieldValues(int $id): Main\Result - removes all user field values for item with ID$id.


© «Bitrix24», 2001-2024
Up