ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
TreeStandardAdapter.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24
26{
27 public function __construct(
28 protected InternalRepoService $repo,
29 protected \ilTree $tree,
30 protected int $user_id
31 ) {
32 }
33 public function isDeleted(int $node_id): bool
34 {
35 return $this->tree->isDeleted($node_id);
36 }
37 public function useCache(bool $use): void
38 {
39 $this->tree->useCache($use);
40 }
41 public function getNodeData(int $id): array
42 {
43 return $this->tree->getNodeData($id);
44 }
45 public function isInTree(int $id): bool
46 {
47 return $this->tree->isInTree($id);
48 }
49 public function getSubTree(array $node): array
50 {
51 return $this->tree->getSubTree($node);
52 }
53
54 public function moveToTrash(int $ref_id): bool
55 {
56 return $this->tree->moveToTrash($ref_id, true, $this->user_id);
57 }
58
62 public function getDeletedTreeNodeIds(array $ids): array
63 {
64 $deleted_ids = [];
65 foreach ($ids as $id) {
66 if ($this->tree->isDeleted($id)) {
67 $deleted_ids[] = $id;
68 }
69 }
70 return $deleted_ids;
71 }
72
73 public function getTree(int $tree_id): TreeInterface
74 {
75 return new self(
76 $this->repo,
77 new \ilTree($tree_id),
79 );
80 }
81
82 public function getTrashTree(int $ref_id): TreeInterface
83 {
85 $tree_id = end($trees);
86
87 if ($tree_id) {
88 if ($tree_id >= 0) {
89 throw new NotInTrashException('Trying to delete node from trash, but node is not in trash: ' . $ref_id);
90 }
91 return new self(
92 $this->repo,
93 new \ilTree($tree_id),
95 );
96 }
97 throw new NotInTrashException('Trying to delete node from trash, but no valid tree id found for node id: ' . $ref_id);
98 }
99
100 public function deleteTree(array $node_data): void
101 {
102 $this->tree->deleteTree($node_data);
103 }
104
109 public function getTrashedSubtrees(int $ref_id): array
110 {
111 $tree_repo = $this->repo->tree();
112 return $tree_repo->getTrashedSubtrees($ref_id);
113 }
114}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(protected InternalRepoService $repo, protected \ilTree $tree, protected int $user_id)
getTrashedSubtrees(int $ref_id)
Get (negative) tree ids of trashed children.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static lookupTreesForNode(int $node_id)
$ref_id
Definition: ltiauth.php:66
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...