• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/baseobject.php
  • Класс: BitrixDiskBaseObject
  • Вызов: BaseObject::restoreInternal
public function restoreInternal($restoredBy)
{
	if(!static::isUniqueName($this->getNameWithoutTrashCanSuffix(), $this->parentId, $this->id))
	{
		$this->name = static::generateUniqueName($this->getNameWithoutTrashCanSuffix(), $this->parentId);
	}

	/** @var ObjectTable $tableClassName */
	$tableClassName = $this->getTableClassName();

	$status = $this->update(array(
		'NAME' => $this->getNameWithoutTrashCanSuffix(),
		'DELETED_TYPE' => $tableClassName::DELETED_TYPE_NONE,
		'UPDATE_TIME' => new DateTime(),
		'UPDATED_BY' => $restoredBy,
	));

	if($status)
	{
		//we have to delete links which are in trashcan. It's special case. @see BitrixDiskBaseObject::markDeletedInternal.
		$links = BaseObject::getModelList(array(
			'filter' => array(
				'REAL_OBJECT_ID' => $this->id,
				'!=DELETED_TYPE' => ObjectTable::DELETED_TYPE_NONE,
			)
		));
		foreach($links as $link)
		{
			if ($link instanceof FileLink)
			{
				$link->delete($restoredBy);
			}
			elseif ($link instanceof FolderLink)
			{
				$link->deleteTree($restoredBy);
			}
		}

		$event = new Event(Driver::INTERNAL_MODULE_ID, "onAfterRestoreObject", array($this, $restoredBy));
		$event->send();
	}

	return $status;
}