ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilDAVClientNode.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
24 use Sabre\DAV\INode;
25 
29 class ilDAVClientNode implements ICollection
30 {
33 
34  protected string $name_of_repository_root = 'ILIAS';
35 
36  public function __construct(
37  protected string $client_name,
38  protected ilWebDAVObjFactory $dav_factory,
39  protected ilWebDAVRepositoryHelper $repository_helper
40  ) {
41  }
42 
43  public function getName(): string
44  {
45  return $this->client_name;
46  }
47 
48  public function getChild($name): INode
49  {
50  try {
51  $ref_id = $this->getRefIdFromName($name);
52 
53  return $this->dav_factory->retrieveDAVObjectByRefID($ref_id);
54  } catch (NotFound) {
55  }
56 
57  return $this->getChildByParentRefId($this->repository_helper, $this->dav_factory, ROOT_FOLDER_ID, $name);
58  }
59 
63  public function getChildren(): array
64  {
65  return $this->getChildrenByParentRefId($this->repository_helper, $this->dav_factory, ROOT_FOLDER_ID);
66  }
67 
68  public function childExists($name): bool
69  {
70  try {
71  $ref_id = $this->getRefIdFromName($name);
72  return $this->repository_helper->objectWithRefIdExists($ref_id) && $this->repository_helper->checkAccess(
73  'read',
74  $ref_id
75  );
76  } catch (BadRequest) {
77  }
78 
79  return $this->checkIfChildExistsByParentRefId(
80  $this->repository_helper,
81  $this->dav_factory,
83  $name
84  );
85  }
86 
87  public function getLastModified(): int
88  {
89  return strtotime('2000-01-01');
90  }
91 
92  protected function getRefIdFromName(string $name): int
93  {
94  $ref_parts = explode('_', $name);
95  if (count($ref_parts) == 2 && ($ref_id = (int) $ref_parts[1]) > 0) {
96  return $ref_id;
97  }
98 
99  throw new NotFound("No id found for $name");
100  }
101 }
const ROOT_FOLDER_ID
Definition: constants.php:32
$ref_id
Definition: ltiauth.php:65
getRefIdFromName(string $name)
__construct(protected string $client_name, protected ilWebDAVObjFactory $dav_factory, protected ilWebDAVRepositoryHelper $repository_helper)