@@ -29,49 +29,49 @@ |
||
29 | 29 | use Sabre\DAV\ICollection; |
30 | 30 | |
31 | 31 | abstract class AbstractTrashFolder extends AbstractTrash implements ICollection, ITrash { |
32 | - public function getChildren(): array { |
|
33 | - $entries = $this->trashManager->listTrashFolder($this->data); |
|
32 | + public function getChildren(): array { |
|
33 | + $entries = $this->trashManager->listTrashFolder($this->data); |
|
34 | 34 | |
35 | - $children = array_map(function (ITrashItem $entry) { |
|
36 | - if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
|
37 | - return new TrashFolderFolder($this->trashManager, $entry); |
|
38 | - } |
|
39 | - return new TrashFolderFile($this->trashManager, $entry); |
|
40 | - }, $entries); |
|
35 | + $children = array_map(function (ITrashItem $entry) { |
|
36 | + if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
|
37 | + return new TrashFolderFolder($this->trashManager, $entry); |
|
38 | + } |
|
39 | + return new TrashFolderFile($this->trashManager, $entry); |
|
40 | + }, $entries); |
|
41 | 41 | |
42 | - return $children; |
|
43 | - } |
|
42 | + return $children; |
|
43 | + } |
|
44 | 44 | |
45 | - public function getChild($name): ITrash { |
|
46 | - $entries = $this->getChildren(); |
|
45 | + public function getChild($name): ITrash { |
|
46 | + $entries = $this->getChildren(); |
|
47 | 47 | |
48 | - foreach ($entries as $entry) { |
|
49 | - if ($entry->getName() === $name) { |
|
50 | - return $entry; |
|
51 | - } |
|
52 | - } |
|
48 | + foreach ($entries as $entry) { |
|
49 | + if ($entry->getName() === $name) { |
|
50 | + return $entry; |
|
51 | + } |
|
52 | + } |
|
53 | 53 | |
54 | - throw new NotFound(); |
|
55 | - } |
|
54 | + throw new NotFound(); |
|
55 | + } |
|
56 | 56 | |
57 | - public function childExists($name): bool { |
|
58 | - try { |
|
59 | - $this->getChild($name); |
|
60 | - return true; |
|
61 | - } catch (NotFound $e) { |
|
62 | - return false; |
|
63 | - } |
|
64 | - } |
|
57 | + public function childExists($name): bool { |
|
58 | + try { |
|
59 | + $this->getChild($name); |
|
60 | + return true; |
|
61 | + } catch (NotFound $e) { |
|
62 | + return false; |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | - public function setName($name) { |
|
67 | - throw new Forbidden(); |
|
68 | - } |
|
66 | + public function setName($name) { |
|
67 | + throw new Forbidden(); |
|
68 | + } |
|
69 | 69 | |
70 | - public function createFile($name, $data = null) { |
|
71 | - throw new Forbidden(); |
|
72 | - } |
|
70 | + public function createFile($name, $data = null) { |
|
71 | + throw new Forbidden(); |
|
72 | + } |
|
73 | 73 | |
74 | - public function createDirectory($name) { |
|
75 | - throw new Forbidden(); |
|
76 | - } |
|
74 | + public function createDirectory($name) { |
|
75 | + throw new Forbidden(); |
|
76 | + } |
|
77 | 77 | } |
@@ -25,11 +25,11 @@ |
||
25 | 25 | namespace OCA\Files_Trashbin\Sabre; |
26 | 26 | |
27 | 27 | class TrashFile extends AbstractTrashFile { |
28 | - public function get() { |
|
29 | - return $this->data->getStorage()->fopen($this->data->getInternalPath() . '.d' . $this->getLastModified(), 'rb'); |
|
30 | - } |
|
28 | + public function get() { |
|
29 | + return $this->data->getStorage()->fopen($this->data->getInternalPath() . '.d' . $this->getLastModified(), 'rb'); |
|
30 | + } |
|
31 | 31 | |
32 | - public function getName(): string { |
|
33 | - return $this->data->getName() . '.d' . $this->getLastModified(); |
|
34 | - } |
|
32 | + public function getName(): string { |
|
33 | + return $this->data->getName() . '.d' . $this->getLastModified(); |
|
34 | + } |
|
35 | 35 | } |
@@ -36,57 +36,57 @@ |
||
36 | 36 | */ |
37 | 37 | interface IAccount extends \JsonSerializable { |
38 | 38 | |
39 | - /** |
|
40 | - * Set a property with data |
|
41 | - * |
|
42 | - * @since 15.0.0 |
|
43 | - * |
|
44 | - * @param string $property Must be one of the PROPERTY_ prefixed constants of \OCP\Accounts\IAccountManager |
|
45 | - * @param string $value |
|
46 | - * @param string $scope Must be one of the VISIBILITY_ prefixed constants of \OCP\Accounts\IAccountManager |
|
47 | - * @param string $verified \OCP\Accounts\IAccountManager::NOT_VERIFIED | \OCP\Accounts\IAccountManager::VERIFICATION_IN_PROGRESS | \OCP\Accounts\IAccountManager::VERIFIED |
|
48 | - * @return IAccount |
|
49 | - */ |
|
50 | - public function setProperty(string $property, string $value, string $scope, string $verified): IAccount; |
|
39 | + /** |
|
40 | + * Set a property with data |
|
41 | + * |
|
42 | + * @since 15.0.0 |
|
43 | + * |
|
44 | + * @param string $property Must be one of the PROPERTY_ prefixed constants of \OCP\Accounts\IAccountManager |
|
45 | + * @param string $value |
|
46 | + * @param string $scope Must be one of the VISIBILITY_ prefixed constants of \OCP\Accounts\IAccountManager |
|
47 | + * @param string $verified \OCP\Accounts\IAccountManager::NOT_VERIFIED | \OCP\Accounts\IAccountManager::VERIFICATION_IN_PROGRESS | \OCP\Accounts\IAccountManager::VERIFIED |
|
48 | + * @return IAccount |
|
49 | + */ |
|
50 | + public function setProperty(string $property, string $value, string $scope, string $verified): IAccount; |
|
51 | 51 | |
52 | - /** |
|
53 | - * Get a property by its key |
|
54 | - * |
|
55 | - * @since 15.0.0 |
|
56 | - * |
|
57 | - * @param string $property Must be one of the PROPERTY_ prefixed constants of \OCP\Accounts\IAccountManager |
|
58 | - * @return IAccountProperty |
|
59 | - * @throws PropertyDoesNotExistException |
|
60 | - */ |
|
61 | - public function getProperty(string $property): IAccountProperty; |
|
52 | + /** |
|
53 | + * Get a property by its key |
|
54 | + * |
|
55 | + * @since 15.0.0 |
|
56 | + * |
|
57 | + * @param string $property Must be one of the PROPERTY_ prefixed constants of \OCP\Accounts\IAccountManager |
|
58 | + * @return IAccountProperty |
|
59 | + * @throws PropertyDoesNotExistException |
|
60 | + */ |
|
61 | + public function getProperty(string $property): IAccountProperty; |
|
62 | 62 | |
63 | - /** |
|
64 | - * Get all properties of an account |
|
65 | - * |
|
66 | - * @since 15.0.0 |
|
67 | - * |
|
68 | - * @return IAccountProperty[] |
|
69 | - */ |
|
70 | - public function getProperties(): array; |
|
63 | + /** |
|
64 | + * Get all properties of an account |
|
65 | + * |
|
66 | + * @since 15.0.0 |
|
67 | + * |
|
68 | + * @return IAccountProperty[] |
|
69 | + */ |
|
70 | + public function getProperties(): array; |
|
71 | 71 | |
72 | - /** |
|
73 | - * Get all properties that match the provided filters for scope and verification status |
|
74 | - * |
|
75 | - * @since 15.0.0 |
|
76 | - * |
|
77 | - * @param string $scope Must be one of the VISIBILITY_ prefixed constants of \OCP\Accounts\IAccountManager |
|
78 | - * @param string $verified \OCP\Accounts\IAccountManager::NOT_VERIFIED | \OCP\Accounts\IAccountManager::VERIFICATION_IN_PROGRESS | \OCP\Accounts\IAccountManager::VERIFIED |
|
79 | - * @return IAccountProperty[] |
|
80 | - */ |
|
81 | - public function getFilteredProperties(string $scope = null, string $verified = null): array; |
|
72 | + /** |
|
73 | + * Get all properties that match the provided filters for scope and verification status |
|
74 | + * |
|
75 | + * @since 15.0.0 |
|
76 | + * |
|
77 | + * @param string $scope Must be one of the VISIBILITY_ prefixed constants of \OCP\Accounts\IAccountManager |
|
78 | + * @param string $verified \OCP\Accounts\IAccountManager::NOT_VERIFIED | \OCP\Accounts\IAccountManager::VERIFICATION_IN_PROGRESS | \OCP\Accounts\IAccountManager::VERIFIED |
|
79 | + * @return IAccountProperty[] |
|
80 | + */ |
|
81 | + public function getFilteredProperties(string $scope = null, string $verified = null): array; |
|
82 | 82 | |
83 | - /** |
|
84 | - * Get the related user for the account data |
|
85 | - * |
|
86 | - * @since 15.0.0 |
|
87 | - * |
|
88 | - * @return IUser |
|
89 | - */ |
|
90 | - public function getUser(): IUser; |
|
83 | + /** |
|
84 | + * Get the related user for the account data |
|
85 | + * |
|
86 | + * @since 15.0.0 |
|
87 | + * |
|
88 | + * @return IUser |
|
89 | + */ |
|
90 | + public function getUser(): IUser; |
|
91 | 91 | |
92 | 92 | } |
@@ -45,45 +45,45 @@ |
||
45 | 45 | interface ISearchService { |
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * generate a search request, based on an array: |
|
50 | - * |
|
51 | - * $request = |
|
52 | - * [ |
|
53 | - * 'providers' => (string/array) 'all' |
|
54 | - * 'author' => (string) owner of the document. |
|
55 | - * 'search' => (string) search string, |
|
56 | - * 'size' => (int) number of items to be return |
|
57 | - * 'page' => (int) page |
|
58 | - * 'parts' => (array) parts of document to search within, |
|
59 | - * 'options' = (array) search options, |
|
60 | - * 'tags' => (array) tags, |
|
61 | - * 'metatags' => (array) metatags, |
|
62 | - * 'subtags' => (array) subtags |
|
63 | - * ] |
|
64 | - * |
|
65 | - * 'providers' can be an array of providerIds |
|
66 | - * |
|
67 | - * @since 15.0.0 |
|
68 | - * |
|
69 | - * @param array $request |
|
70 | - * |
|
71 | - * @return ISearchRequest |
|
72 | - */ |
|
73 | - public function generateSearchRequest(array $request): ISearchRequest; |
|
48 | + /** |
|
49 | + * generate a search request, based on an array: |
|
50 | + * |
|
51 | + * $request = |
|
52 | + * [ |
|
53 | + * 'providers' => (string/array) 'all' |
|
54 | + * 'author' => (string) owner of the document. |
|
55 | + * 'search' => (string) search string, |
|
56 | + * 'size' => (int) number of items to be return |
|
57 | + * 'page' => (int) page |
|
58 | + * 'parts' => (array) parts of document to search within, |
|
59 | + * 'options' = (array) search options, |
|
60 | + * 'tags' => (array) tags, |
|
61 | + * 'metatags' => (array) metatags, |
|
62 | + * 'subtags' => (array) subtags |
|
63 | + * ] |
|
64 | + * |
|
65 | + * 'providers' can be an array of providerIds |
|
66 | + * |
|
67 | + * @since 15.0.0 |
|
68 | + * |
|
69 | + * @param array $request |
|
70 | + * |
|
71 | + * @return ISearchRequest |
|
72 | + */ |
|
73 | + public function generateSearchRequest(array $request): ISearchRequest; |
|
74 | 74 | |
75 | 75 | |
76 | - /** |
|
77 | - * Search documents |
|
78 | - * |
|
79 | - * @since 15.0.0 |
|
80 | - * |
|
81 | - * @param string $userId |
|
82 | - * @param ISearchRequest $searchRequest |
|
83 | - * |
|
84 | - * @return ISearchResult[] |
|
85 | - */ |
|
86 | - public function search(string $userId, ISearchRequest $searchRequest): array; |
|
76 | + /** |
|
77 | + * Search documents |
|
78 | + * |
|
79 | + * @since 15.0.0 |
|
80 | + * |
|
81 | + * @param string $userId |
|
82 | + * @param ISearchRequest $searchRequest |
|
83 | + * |
|
84 | + * @return ISearchResult[] |
|
85 | + */ |
|
86 | + public function search(string $userId, ISearchRequest $searchRequest): array; |
|
87 | 87 | |
88 | 88 | } |
89 | 89 |
@@ -46,41 +46,41 @@ |
||
46 | 46 | interface IIndexOptions { |
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * Get the value (as a string) for an option. |
|
51 | - * |
|
52 | - * @since 15.0.0 |
|
53 | - * |
|
54 | - * @param string $option |
|
55 | - * @param string $default |
|
56 | - * |
|
57 | - * @return string |
|
58 | - */ |
|
59 | - public function getOption(string $option, string $default = ''): string; |
|
49 | + /** |
|
50 | + * Get the value (as a string) for an option. |
|
51 | + * |
|
52 | + * @since 15.0.0 |
|
53 | + * |
|
54 | + * @param string $option |
|
55 | + * @param string $default |
|
56 | + * |
|
57 | + * @return string |
|
58 | + */ |
|
59 | + public function getOption(string $option, string $default = ''): string; |
|
60 | 60 | |
61 | - /** |
|
62 | - * Get the value (as an array) for an option. |
|
63 | - * |
|
64 | - * @since 15.0.0 |
|
65 | - * |
|
66 | - * @param string $option |
|
67 | - * @param array $default |
|
68 | - * |
|
69 | - * @return array |
|
70 | - */ |
|
71 | - public function getOptionArray(string $option, array $default = []): array; |
|
61 | + /** |
|
62 | + * Get the value (as an array) for an option. |
|
63 | + * |
|
64 | + * @since 15.0.0 |
|
65 | + * |
|
66 | + * @param string $option |
|
67 | + * @param array $default |
|
68 | + * |
|
69 | + * @return array |
|
70 | + */ |
|
71 | + public function getOptionArray(string $option, array $default = []): array; |
|
72 | 72 | |
73 | - /** |
|
74 | - * Get the value (as an boolean) for an option. |
|
75 | - * |
|
76 | - * @since 15.0.0 |
|
77 | - * |
|
78 | - * @param string $option |
|
79 | - * @param bool $default |
|
80 | - * |
|
81 | - * @return bool |
|
82 | - */ |
|
83 | - public function getOptionBool(string $option, bool $default): bool; |
|
73 | + /** |
|
74 | + * Get the value (as an boolean) for an option. |
|
75 | + * |
|
76 | + * @since 15.0.0 |
|
77 | + * |
|
78 | + * @param string $option |
|
79 | + * @param bool $default |
|
80 | + * |
|
81 | + * @return bool |
|
82 | + */ |
|
83 | + public function getOptionBool(string $option, bool $default): bool; |
|
84 | 84 | |
85 | 85 | } |
86 | 86 |
@@ -26,16 +26,16 @@ |
||
26 | 26 | use OC\Authentication\Token\IToken; |
27 | 27 | |
28 | 28 | class ExpiredTokenException extends InvalidTokenException { |
29 | - /** @var IToken */ |
|
30 | - private $token; |
|
29 | + /** @var IToken */ |
|
30 | + private $token; |
|
31 | 31 | |
32 | - public function __construct(IToken $token) { |
|
33 | - parent::__construct(); |
|
32 | + public function __construct(IToken $token) { |
|
33 | + parent::__construct(); |
|
34 | 34 | |
35 | - $this->token = $token; |
|
36 | - } |
|
35 | + $this->token = $token; |
|
36 | + } |
|
37 | 37 | |
38 | - public function getToken(): IToken { |
|
39 | - return $this->token; |
|
40 | - } |
|
38 | + public function getToken(): IToken { |
|
39 | + return $this->token; |
|
40 | + } |
|
41 | 41 | } |
@@ -25,12 +25,12 @@ |
||
25 | 25 | * @since 15.0.0 |
26 | 26 | */ |
27 | 27 | interface IVersionManager extends IVersionBackend { |
28 | - /** |
|
29 | - * Register a new backend |
|
30 | - * |
|
31 | - * @param string $storageType |
|
32 | - * @param IVersionBackend $backend |
|
33 | - * @since 15.0.0 |
|
34 | - */ |
|
35 | - public function registerBackend(string $storageType, IVersionBackend $backend); |
|
28 | + /** |
|
29 | + * Register a new backend |
|
30 | + * |
|
31 | + * @param string $storageType |
|
32 | + * @param IVersionBackend $backend |
|
33 | + * @since 15.0.0 |
|
34 | + */ |
|
35 | + public function registerBackend(string $storageType, IVersionBackend $backend); |
|
36 | 36 | } |
@@ -33,74 +33,74 @@ |
||
33 | 33 | |
34 | 34 | class VersionRoot implements ICollection { |
35 | 35 | |
36 | - /** @var IUser */ |
|
37 | - private $user; |
|
36 | + /** @var IUser */ |
|
37 | + private $user; |
|
38 | 38 | |
39 | - /** @var IRootFolder */ |
|
40 | - private $rootFolder; |
|
39 | + /** @var IRootFolder */ |
|
40 | + private $rootFolder; |
|
41 | 41 | |
42 | - /** @var IVersionManager */ |
|
43 | - private $versionManager; |
|
42 | + /** @var IVersionManager */ |
|
43 | + private $versionManager; |
|
44 | 44 | |
45 | - public function __construct(IUser $user, IRootFolder $rootFolder, IVersionManager $versionManager) { |
|
46 | - $this->user = $user; |
|
47 | - $this->rootFolder = $rootFolder; |
|
48 | - $this->versionManager = $versionManager; |
|
49 | - } |
|
45 | + public function __construct(IUser $user, IRootFolder $rootFolder, IVersionManager $versionManager) { |
|
46 | + $this->user = $user; |
|
47 | + $this->rootFolder = $rootFolder; |
|
48 | + $this->versionManager = $versionManager; |
|
49 | + } |
|
50 | 50 | |
51 | - public function delete() { |
|
52 | - throw new Forbidden(); |
|
53 | - } |
|
51 | + public function delete() { |
|
52 | + throw new Forbidden(); |
|
53 | + } |
|
54 | 54 | |
55 | - public function getName(): string { |
|
56 | - return 'versions'; |
|
57 | - } |
|
55 | + public function getName(): string { |
|
56 | + return 'versions'; |
|
57 | + } |
|
58 | 58 | |
59 | - public function setName($name) { |
|
60 | - throw new Forbidden(); |
|
61 | - } |
|
59 | + public function setName($name) { |
|
60 | + throw new Forbidden(); |
|
61 | + } |
|
62 | 62 | |
63 | - public function createFile($name, $data = null) { |
|
64 | - throw new Forbidden(); |
|
65 | - } |
|
63 | + public function createFile($name, $data = null) { |
|
64 | + throw new Forbidden(); |
|
65 | + } |
|
66 | 66 | |
67 | - public function createDirectory($name) { |
|
68 | - throw new Forbidden(); |
|
69 | - } |
|
67 | + public function createDirectory($name) { |
|
68 | + throw new Forbidden(); |
|
69 | + } |
|
70 | 70 | |
71 | - public function getChild($name) { |
|
72 | - $userFolder = $this->rootFolder->getUserFolder($this->user->getUID()); |
|
71 | + public function getChild($name) { |
|
72 | + $userFolder = $this->rootFolder->getUserFolder($this->user->getUID()); |
|
73 | 73 | |
74 | - $fileId = (int)$name; |
|
75 | - $nodes = $userFolder->getById($fileId); |
|
74 | + $fileId = (int)$name; |
|
75 | + $nodes = $userFolder->getById($fileId); |
|
76 | 76 | |
77 | - if ($nodes === []) { |
|
78 | - throw new NotFound(); |
|
79 | - } |
|
77 | + if ($nodes === []) { |
|
78 | + throw new NotFound(); |
|
79 | + } |
|
80 | 80 | |
81 | - $node = array_pop($nodes); |
|
81 | + $node = array_pop($nodes); |
|
82 | 82 | |
83 | - if (!$node instanceof File) { |
|
84 | - throw new NotFound(); |
|
85 | - } |
|
83 | + if (!$node instanceof File) { |
|
84 | + throw new NotFound(); |
|
85 | + } |
|
86 | 86 | |
87 | - return new VersionCollection($userFolder, $node, $this->user, $this->versionManager); |
|
88 | - } |
|
87 | + return new VersionCollection($userFolder, $node, $this->user, $this->versionManager); |
|
88 | + } |
|
89 | 89 | |
90 | - public function getChildren(): array { |
|
91 | - return []; |
|
92 | - } |
|
90 | + public function getChildren(): array { |
|
91 | + return []; |
|
92 | + } |
|
93 | 93 | |
94 | - public function childExists($name): bool { |
|
95 | - try { |
|
96 | - $this->getChild($name); |
|
97 | - return true; |
|
98 | - } catch (NotFound $e) { |
|
99 | - return false; |
|
100 | - } |
|
101 | - } |
|
94 | + public function childExists($name): bool { |
|
95 | + try { |
|
96 | + $this->getChild($name); |
|
97 | + return true; |
|
98 | + } catch (NotFound $e) { |
|
99 | + return false; |
|
100 | + } |
|
101 | + } |
|
102 | 102 | |
103 | - public function getLastModified(): int { |
|
104 | - return 0; |
|
105 | - } |
|
103 | + public function getLastModified(): int { |
|
104 | + return 0; |
|
105 | + } |
|
106 | 106 | } |
@@ -35,76 +35,76 @@ |
||
35 | 35 | use Sabre\DAV\ICollection; |
36 | 36 | |
37 | 37 | class VersionCollection implements ICollection { |
38 | - /** @var Folder */ |
|
39 | - private $userFolder; |
|
40 | - |
|
41 | - /** @var File */ |
|
42 | - private $file; |
|
43 | - |
|
44 | - /** @var IUser */ |
|
45 | - private $user; |
|
46 | - |
|
47 | - /** @var IVersionManager */ |
|
48 | - private $versionManager; |
|
49 | - |
|
50 | - public function __construct(Folder $userFolder, File $file, IUser $user, IVersionManager $versionManager) { |
|
51 | - $this->userFolder = $userFolder; |
|
52 | - $this->file = $file; |
|
53 | - $this->user = $user; |
|
54 | - $this->versionManager = $versionManager; |
|
55 | - } |
|
56 | - |
|
57 | - public function createFile($name, $data = null) { |
|
58 | - throw new Forbidden(); |
|
59 | - } |
|
60 | - |
|
61 | - public function createDirectory($name) { |
|
62 | - throw new Forbidden(); |
|
63 | - } |
|
64 | - |
|
65 | - public function getChild($name) { |
|
66 | - /** @var VersionFile[] $versions */ |
|
67 | - $versions = $this->getChildren(); |
|
68 | - |
|
69 | - foreach ($versions as $version) { |
|
70 | - if ($version->getName() === $name) { |
|
71 | - return $version; |
|
72 | - } |
|
73 | - } |
|
74 | - |
|
75 | - throw new NotFound(); |
|
76 | - } |
|
77 | - |
|
78 | - public function getChildren(): array { |
|
79 | - $versions = $this->versionManager->getVersionsForFile($this->user, $this->file); |
|
80 | - |
|
81 | - return array_map(function (IVersion $version) { |
|
82 | - return new VersionFile($version, $this->versionManager); |
|
83 | - }, $versions); |
|
84 | - } |
|
85 | - |
|
86 | - public function childExists($name): bool { |
|
87 | - try { |
|
88 | - $this->getChild($name); |
|
89 | - return true; |
|
90 | - } catch (NotFound $e) { |
|
91 | - return false; |
|
92 | - } |
|
93 | - } |
|
94 | - |
|
95 | - public function delete() { |
|
96 | - throw new Forbidden(); |
|
97 | - } |
|
98 | - |
|
99 | - public function getName(): string { |
|
100 | - return (string)$this->file->getId(); |
|
101 | - } |
|
102 | - |
|
103 | - public function setName($name) { |
|
104 | - throw new Forbidden(); |
|
105 | - } |
|
106 | - |
|
107 | - public function getLastModified(): int { |
|
108 | - return 0; |
|
109 | - } |
|
38 | + /** @var Folder */ |
|
39 | + private $userFolder; |
|
40 | + |
|
41 | + /** @var File */ |
|
42 | + private $file; |
|
43 | + |
|
44 | + /** @var IUser */ |
|
45 | + private $user; |
|
46 | + |
|
47 | + /** @var IVersionManager */ |
|
48 | + private $versionManager; |
|
49 | + |
|
50 | + public function __construct(Folder $userFolder, File $file, IUser $user, IVersionManager $versionManager) { |
|
51 | + $this->userFolder = $userFolder; |
|
52 | + $this->file = $file; |
|
53 | + $this->user = $user; |
|
54 | + $this->versionManager = $versionManager; |
|
55 | + } |
|
56 | + |
|
57 | + public function createFile($name, $data = null) { |
|
58 | + throw new Forbidden(); |
|
59 | + } |
|
60 | + |
|
61 | + public function createDirectory($name) { |
|
62 | + throw new Forbidden(); |
|
63 | + } |
|
64 | + |
|
65 | + public function getChild($name) { |
|
66 | + /** @var VersionFile[] $versions */ |
|
67 | + $versions = $this->getChildren(); |
|
68 | + |
|
69 | + foreach ($versions as $version) { |
|
70 | + if ($version->getName() === $name) { |
|
71 | + return $version; |
|
72 | + } |
|
73 | + } |
|
74 | + |
|
75 | + throw new NotFound(); |
|
76 | + } |
|
77 | + |
|
78 | + public function getChildren(): array { |
|
79 | + $versions = $this->versionManager->getVersionsForFile($this->user, $this->file); |
|
80 | + |
|
81 | + return array_map(function (IVersion $version) { |
|
82 | + return new VersionFile($version, $this->versionManager); |
|
83 | + }, $versions); |
|
84 | + } |
|
85 | + |
|
86 | + public function childExists($name): bool { |
|
87 | + try { |
|
88 | + $this->getChild($name); |
|
89 | + return true; |
|
90 | + } catch (NotFound $e) { |
|
91 | + return false; |
|
92 | + } |
|
93 | + } |
|
94 | + |
|
95 | + public function delete() { |
|
96 | + throw new Forbidden(); |
|
97 | + } |
|
98 | + |
|
99 | + public function getName(): string { |
|
100 | + return (string)$this->file->getId(); |
|
101 | + } |
|
102 | + |
|
103 | + public function setName($name) { |
|
104 | + throw new Forbidden(); |
|
105 | + } |
|
106 | + |
|
107 | + public function getLastModified(): int { |
|
108 | + return 0; |
|
109 | + } |
|
110 | 110 | } |