• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/showsession.php
  • Класс: BitrixDiskShowSession
  • Вызов: ShowSession::delete
public function delete()
{
	$documentHandlersManager = Driver::getInstance()->getDocumentHandlersManager();
	$documentHandler = $documentHandlersManager->getHandlerByCode($this->service);

	if(!$documentHandler)
	{
		$this->errorCollection->add($documentHandlersManager->getErrors());

		return false;
	}

	$documentHandler->setUserId($this->ownerId);
	if(!$documentHandler->queryAccessToken()->hasAccessToken())
	{
		$this->errorCollection[] = new Error('Could not get token for user.');

		return false;
	}

	$fileData = new DocumentFileData;
	$fileData->setId($this->serviceFileId);

	$fileMetadata = $documentHandler->getFileMetadata($fileData);
	if(!$fileMetadata)
	{
		if($documentHandler->getErrorByCode($documentHandler::ERROR_CODE_NOT_FOUND))
		{
			return $this->deleteInternal();
		}

		$this->errorCollection->add($documentHandler->getErrors());

		return false;
	}

	$oldMetadata = array();
	if($this->etag)
	{
		$oldMetadata = array(
			'etag' => $this->etag,
		);
	}
	if($documentHandler->wasChangedAfterCreation($fileMetadata, $oldMetadata))
	{
		//$this->errorCollection[] = new Error('File in the cloud was changed.');

		return $this->deleteInternal();
	}

	if($documentHandler->deleteFile($fileData))
	{
		return $this->deleteInternal();
	}

	return false;
}