2018-09-03 12:30:10 -04:00
|
|
|
<?php
|
2019-12-03 13:57:53 -05:00
|
|
|
|
2018-09-10 08:40:35 -04:00
|
|
|
declare(strict_types=1);
|
2019-12-03 13:57:53 -05:00
|
|
|
|
2018-09-03 12:30:10 -04:00
|
|
|
/**
|
2024-06-02 09:26:54 -04:00
|
|
|
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2018-09-03 12:30:10 -04:00
|
|
|
*/
|
|
|
|
|
namespace OCA\Files_Trashbin\Sabre;
|
|
|
|
|
|
2018-09-10 08:40:35 -04:00
|
|
|
use OCA\Files_Trashbin\Trash\ITrashItem;
|
|
|
|
|
use OCA\Files_Trashbin\Trash\ITrashManager;
|
2018-09-03 12:30:10 -04:00
|
|
|
use OCP\Files\FileInfo;
|
2024-04-11 20:39:59 -04:00
|
|
|
use OCP\IUser;
|
2018-09-03 12:30:10 -04:00
|
|
|
|
|
|
|
|
abstract class AbstractTrash implements ITrash {
|
2024-10-18 06:04:22 -04:00
|
|
|
public function __construct(
|
|
|
|
|
protected ITrashManager $trashManager,
|
|
|
|
|
protected ITrashItem $data,
|
|
|
|
|
) {
|
2018-09-03 12:30:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getFilename(): string {
|
|
|
|
|
return $this->data->getName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getDeletionTime(): int {
|
2018-09-10 08:40:35 -04:00
|
|
|
return $this->data->getDeletedTime();
|
2018-09-03 12:30:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getFileId(): int {
|
|
|
|
|
return $this->data->getId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getFileInfo(): FileInfo {
|
|
|
|
|
return $this->data;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-23 09:43:39 -05:00
|
|
|
/**
|
|
|
|
|
* @psalm-suppress ImplementedReturnTypeMismatch \Sabre\DAV\IFile::getSize signature does not support 32bit
|
|
|
|
|
* @return int|float
|
|
|
|
|
*/
|
2023-01-23 09:03:56 -05:00
|
|
|
public function getSize(): int|float {
|
2018-09-03 12:30:10 -04:00
|
|
|
return $this->data->getSize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getLastModified(): int {
|
|
|
|
|
return $this->data->getMtime();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getContentType(): string {
|
|
|
|
|
return $this->data->getMimetype();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getETag(): string {
|
|
|
|
|
return $this->data->getEtag();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getName(): string {
|
|
|
|
|
return $this->data->getName();
|
|
|
|
|
}
|
2018-09-10 08:40:35 -04:00
|
|
|
|
|
|
|
|
public function getOriginalLocation(): string {
|
2018-10-17 09:21:09 -04:00
|
|
|
return $this->data->getOriginalLocation();
|
2018-09-10 08:40:35 -04:00
|
|
|
}
|
|
|
|
|
|
2019-10-02 10:36:53 -04:00
|
|
|
public function getTitle(): string {
|
|
|
|
|
return $this->data->getTitle();
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-11 20:39:59 -04:00
|
|
|
public function getDeletedBy(): ?IUser {
|
|
|
|
|
return $this->data->getDeletedBy();
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-10 08:40:35 -04:00
|
|
|
public function delete() {
|
2018-10-17 09:21:09 -04:00
|
|
|
$this->trashManager->removeItem($this->data);
|
2018-09-10 08:40:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function restore(): bool {
|
|
|
|
|
$this->trashManager->restoreItem($this->data);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2018-09-03 12:30:10 -04:00
|
|
|
}
|