TaskObject::wakeUpObject

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. TaskObject
  4. wakeUpObject
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/internals/taskobject.php
  • Класс: BitrixTasksInternalsTaskObject
  • Вызов: TaskObject::wakeUpObject
static function wakeUpObject($data): TaskObject
{
	if (!is_array($data))
	{
		return parent::wakeUp($data);
	}

	$fields = TaskTable::getEntity()->getFields();

	$wakeUpData = [];
	$customData = [];
	foreach ($data as $field => $value)
	{
		if (array_key_exists($field, $fields))
		{

			if (
				$fields[$field] instanceof DateTimeField
				&& is_numeric($value)
			)
			{
				$wakeUpData[$field] = DateTime::createFromTimestampGmt($value);
			}
			else
			{
				$wakeUpData[$field] = $value;
			}
		}
		else
		{
			$customData[$field] = $value;
		}
	}

	$object = parent::wakeUp($wakeUpData);
	foreach ($customData as $field => $value)
	{
		$object->customData->set($field, $value);
	}

	return $object;
}

Добавить комментарий