ILIAS  release_8 Revision v8.24
class.ilDAVClientNode.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21use Sabre\DAV\Exception\BadRequest;
22use Sabre\DAV\Exception\NotFound;
23use Sabre\DAV\ICollection;
24use Sabre\DAV\INode;
25
29class ilDAVClientNode implements ICollection
30{
31 use ilWebDAVReadOnlyNodeWriteFunctionsTrait;
32 use ilWebDAVAccessChildrenFunctionsTrait;
33
36 protected string $client_name;
37 protected string $name_of_repository_root;
38
39 public function __construct(
40 string $client_name,
43 ) {
44 $this->dav_factory = $dav_factory;
45 $this->repository_helper = $repository_helper;
46 $this->client_name = $client_name;
47 $this->name_of_repository_root = 'ILIAS';
48 }
49
50 public function getName(): string
51 {
52 return $this->client_name;
53 }
54
55 public function getChild($name): INode
56 {
57 try {
59
60 return $this->dav_factory->retrieveDAVObjectByRefID($ref_id);
61 } catch (NotFound $e) {
62 }
63
64 return $this->getChildByParentRefId($this->repository_helper, $this->dav_factory, ROOT_FOLDER_ID, $name);
65 }
66
70 public function getChildren(): array
71 {
72 return $this->getChildrenByParentRefId($this->repository_helper, $this->dav_factory, ROOT_FOLDER_ID);
73 }
74
75 public function childExists($name): bool
76 {
77 try {
79 return $this->repository_helper->objectWithRefIdExists($ref_id) && $this->repository_helper->checkAccess('read', $ref_id);
80 } catch (BadRequest $e) {
81 }
82
83 return $this->checkIfChildExistsByParentRefId($this->repository_helper, $this->dav_factory, ROOT_FOLDER_ID, $name);
84 }
85
86 public function getLastModified(): int
87 {
88 return strtotime('2000-01-01');
89 }
90
91 protected function getRefIdFromName(string $name): int
92 {
93 $ref_parts = explode('_', $name);
94 if (count($ref_parts) == 2 && ($ref_id = (int) $ref_parts[1]) > 0) {
95 return $ref_id;
96 }
97
98 throw new NotFound("No id found for $name");
99 }
100}
ilWebDAVRepositoryHelper $repository_helper
__construct(string $client_name, ilWebDAVObjFactory $dav_factory, ilWebDAVRepositoryHelper $repository_helper)
getRefIdFromName(string $name)
ilWebDAVObjFactory $dav_factory
const ROOT_FOLDER_ID
Definition: constants.php:32
$ref_id
Definition: ltiauth.php:67
if($format !==null) $name
Definition: metadata.php:247
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: AsyncNode.php:21