Skip to content

Commit 9912bb4

Browse files
committed
feat(trash): Add getTrashRootItem to ITrashBackend
Now all backends implement it and we don't need the legacy fallback anymore. Signed-off-by: Carl Schwan <carl@carlschwan.eu>
1 parent 77c5d71 commit 9912bb4

3 files changed

Lines changed: 12 additions & 31 deletions

File tree

apps/files_trashbin/lib/Trash/ITrashBackend.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ public function listTrashRoot(IUser $user): array;
3535
*/
3636
public function listTrashFolder(ITrashItem $folder): array;
3737

38+
/**
39+
* Get a specific item in the root of the trashbin
40+
*
41+
* @param IUser $user
42+
* @return ?ITrashItem
43+
* @since 35.0.0
44+
*/
45+
public function getTrashRootItem(IUser $user, string $name): ?ITrashItem;
46+
3847
/**
3948
* Restore a trashbin item
4049
*

apps/files_trashbin/lib/Trash/ITrashManager.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,6 @@ interface ITrashManager extends ITrashBackend {
2121
*/
2222
public function registerBackend(string $storageType, ITrashBackend $backend);
2323

24-
/**
25-
* List all trash items in the root of the trashbin
26-
*
27-
* @param IUser $user
28-
* @return ITrashItem[]
29-
* @since 15.0.0
30-
*/
31-
#[\Override]
32-
public function listTrashRoot(IUser $user): array;
33-
34-
/**
35-
* Get a specific item in the root of the trashbin
36-
*
37-
* @param IUser $user
38-
* @return ?ITrashItem
39-
* @since 35.0.0
40-
*/
41-
public function getTrashRootItem(IUser $user, string $name): ?ITrashItem;
42-
4324
/**
4425
* Temporally prevent files from being moved to the trash
4526
*

apps/files_trashbin/lib/Trash/TrashManager.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,9 @@ public function listTrashRoot(IUser $user): array {
4242
#[\Override]
4343
public function getTrashRootItem(IUser $user, string $name): ?ITrashItem {
4444
foreach ($this->getBackends() as $backend) {
45-
if (method_exists($backend, 'getTrashRootItem')) {
46-
$item = $backend->getTrashRootItem($user, $name);
47-
if ($item !== null) {
48-
return $item;
49-
}
50-
} else {
51-
$items = $backend->listTrashRoot($user);
52-
foreach ($items as $item) {
53-
if ($item->getName() === $name) {
54-
return $item;
55-
}
56-
}
45+
$item = $backend->getTrashRootItem($user, $name);
46+
if ($item !== null) {
47+
return $item;
5748
}
5849
}
5950
return null;

0 commit comments

Comments
 (0)